diff --git a/packages/stream_chat/lib/src/core/models/filter.dart b/packages/stream_chat/lib/src/core/models/filter.dart index eb3932ff..6551d403 100644 --- a/packages/stream_chat/lib/src/core/models/filter.dart +++ b/packages/stream_chat/lib/src/core/models/filter.dart @@ -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 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