added not exists filter
This commit is contained in:
@@ -40,9 +40,12 @@ enum FilterOperator {
|
|||||||
/// Matches values with the specified prefix.
|
/// Matches values with the specified prefix.
|
||||||
autoComplete,
|
autoComplete,
|
||||||
|
|
||||||
/// Matches values that exist/don't exist based on the specified boolean value.
|
/// Matches values that exist.
|
||||||
exists,
|
exists,
|
||||||
|
|
||||||
|
/// Matches values that don't exist.
|
||||||
|
notExists,
|
||||||
|
|
||||||
/// Matches all the values specified in an array.
|
/// Matches all the values specified in an array.
|
||||||
and,
|
and,
|
||||||
|
|
||||||
@@ -163,9 +166,13 @@ class Filter extends Equatable {
|
|||||||
factory Filter.autoComplete(String key, String text) =>
|
factory Filter.autoComplete(String key, String text) =>
|
||||||
Filter._(operator: FilterOperator.autoComplete, key: key, value: text);
|
Filter._(operator: FilterOperator.autoComplete, key: key, value: text);
|
||||||
|
|
||||||
/// Matches values that exist/don't exist based on the specified boolean value.
|
/// Matches values that exist.
|
||||||
factory Filter.exists(String key, {bool exists = true}) =>
|
factory Filter.exists(String key) =>
|
||||||
Filter._(operator: FilterOperator.exists, key: key, value: exists);
|
Filter._(operator: FilterOperator.exists, key: key, value: true);
|
||||||
|
|
||||||
|
/// Matches values that don't exist.
|
||||||
|
factory Filter.notExists(String key) =>
|
||||||
|
Filter._(operator: FilterOperator.exists, key: key, value: false);
|
||||||
|
|
||||||
/// Matches any list that contains the specified values
|
/// Matches any list that contains the specified values
|
||||||
factory Filter.contains(String key, Object value) =>
|
factory Filter.contains(String key, Object value) =>
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ void main() {
|
|||||||
|
|
||||||
test('notExists', () {
|
test('notExists', () {
|
||||||
const key = 'testKey';
|
const key = 'testKey';
|
||||||
final filter = Filter.exists(key, exists: false);
|
final filter = Filter.notExists(key);
|
||||||
expect(filter.key, key);
|
expect(filter.key, key);
|
||||||
expect(filter.value, isFalse);
|
expect(filter.value, isFalse);
|
||||||
expect(filter.operator, FilterOperator.exists.rawValue);
|
expect(filter.operator, FilterOperator.exists.rawValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user