feat(llc): add contains and empty filters
This commit is contained in:
@@ -51,6 +51,9 @@ enum FilterOperator {
|
|||||||
|
|
||||||
/// Matches none of the values specified in an array.
|
/// Matches none of the values specified in an array.
|
||||||
nor,
|
nor,
|
||||||
|
|
||||||
|
/// Matches any list that contains the specified values
|
||||||
|
contains,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper extension for [FilterOperator]
|
/// Helper extension for [FilterOperator]
|
||||||
@@ -71,6 +74,7 @@ extension FilterOperatorX on FilterOperator {
|
|||||||
FilterOperator.and: '\$and',
|
FilterOperator.and: '\$and',
|
||||||
FilterOperator.or: '\$or',
|
FilterOperator.or: '\$or',
|
||||||
FilterOperator.nor: '\$nor',
|
FilterOperator.nor: '\$nor',
|
||||||
|
FilterOperator.contains: '\$contains',
|
||||||
}[this]!;
|
}[this]!;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +161,10 @@ class Filter extends Equatable {
|
|||||||
factory Filter.exists(String key, {bool exists = true}) =>
|
factory Filter.exists(String key, {bool exists = true}) =>
|
||||||
Filter._(operator: FilterOperator.exists, key: key, value: exists);
|
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.
|
/// Creates a custom [Filter] if there isn't one already available.
|
||||||
const factory Filter.custom({
|
const factory Filter.custom({
|
||||||
required Object value,
|
required Object value,
|
||||||
@@ -164,6 +172,9 @@ class Filter extends Equatable {
|
|||||||
String? key,
|
String? key,
|
||||||
}) = Filter.__;
|
}) = Filter.__;
|
||||||
|
|
||||||
|
/// An empty filter
|
||||||
|
factory Filter.empty() => const Filter.raw(value: {});
|
||||||
|
|
||||||
/// Creates a custom [Filter] from a raw map value
|
/// Creates a custom [Filter] from a raw map value
|
||||||
///
|
///
|
||||||
/// ```dart
|
/// ```dart
|
||||||
|
|||||||
Reference in New Issue
Block a user