Merge pull request #708 from GetStream/add-filter

feat(llc): added not exists filter
This commit is contained in:
Salvatore Giordano
2021-10-01 09:26:08 +02:00
committed by GitHub
4 changed files with 18 additions and 2 deletions
@@ -104,7 +104,16 @@ Filter.autoComplete('name', 'demo')
The 'exists' filter matches values that exist, or don't exist, based on the specified boolean value. The 'exists' filter matches values that exist, or don't exist, based on the specified boolean value.
```dart ```dart
Filter.exists('name', true) Filter.exists('name')
```
#### Filter.notExists
The 'notExists' filter checks if the specified key doesn't exist. This is a simplified call to `Filter.exists`
with the value set to false.
```dart
Filter.notExists('name')
``` ```
#### Filter.contains #### Filter.contains
+4
View File
@@ -1,5 +1,9 @@
## Upcoming ## Upcoming
✅ Added
- Added `Filter.notExists`.
🐞 Fixed 🐞 Fixed
- [[#710]](https://github.com/GetStream/stream-chat-flutter/issues/710) Fixed JWT requiring using `String` as id. - [[#710]](https://github.com/GetStream/stream-chat-flutter/issues/710) Fixed JWT requiring using `String` as id.
@@ -167,6 +167,9 @@ 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 values that don't exist.
factory Filter.notExists(String key) => Filter.exists(key, exists: 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) =>
Filter._(operator: FilterOperator.contains, key: key, value: value); Filter._(operator: FilterOperator.contains, key: key, value: 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);