feat(llc): add contains and empty filters

This commit is contained in:
Salvatore Giordano
2021-09-07 10:02:05 +02:00
parent d31a56f222
commit 395f5e6c64
@@ -51,6 +51,9 @@ enum FilterOperator {
/// Matches none of the values specified in an array.
nor,
/// Matches any list that contains the specified values
contains,
}
/// Helper extension for [FilterOperator]
@@ -71,6 +74,7 @@ extension FilterOperatorX on FilterOperator {
FilterOperator.and: '\$and',
FilterOperator.or: '\$or',
FilterOperator.nor: '\$nor',
FilterOperator.contains: '\$contains',
}[this]!;
}
@@ -157,6 +161,10 @@ class Filter extends Equatable {
factory Filter.exists(String key, {bool exists = true}) =>
Filter._(operator: FilterOperator.exists, key: key, value: exists);
/// Matches any list that contains the specified values
factory Filter.contains(String key, List<Object> values) =>
Filter._(operator: FilterOperator.contains, key: key, value: values);
/// Creates a custom [Filter] if there isn't one already available.
const factory Filter.custom({
required Object value,
@@ -164,6 +172,9 @@ class Filter extends Equatable {
String? key,
}) = Filter.__;
/// An empty filter
factory Filter.empty() => const Filter.raw(value: {});
/// Creates a custom [Filter] from a raw map value
///
/// ```dart