From 2c0eaaafab89179e2f8ed94468672cfa1876310e Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Sun, 8 Aug 2021 22:27:40 +0530 Subject: [PATCH 1/6] added new guide --- .../docs/Flutter/guides/understanding_filters.mdx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docusaurus/docs/Flutter/guides/understanding_filters.mdx diff --git a/docusaurus/docs/Flutter/guides/understanding_filters.mdx b/docusaurus/docs/Flutter/guides/understanding_filters.mdx new file mode 100644 index 00000000..47d72e1f --- /dev/null +++ b/docusaurus/docs/Flutter/guides/understanding_filters.mdx @@ -0,0 +1,15 @@ +--- +id: understanding_filters +sidebar_position: 10 +title: Understanding Filters +--- + +Understanding Filters + +### Introduction + +Filters are used to get a specific subset of objects (channels, users, messages, members, etc) which +fit the conditions specified. Earlier versions of the SDK contained String-based filters which are now replaced by type-safe +filters. This guide aims to explain the different types of filters and how to use them. + + From ff4baabcad05c9b75deae446fef636e24b731673 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 9 Aug 2021 16:38:02 +0530 Subject: [PATCH 2/6] added guides --- .../Flutter/guides/understanding_filters.mdx | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/docusaurus/docs/Flutter/guides/understanding_filters.mdx b/docusaurus/docs/Flutter/guides/understanding_filters.mdx index 47d72e1f..8a6fc925 100644 --- a/docusaurus/docs/Flutter/guides/understanding_filters.mdx +++ b/docusaurus/docs/Flutter/guides/understanding_filters.mdx @@ -12,4 +12,132 @@ Filters are used to get a specific subset of objects (channels, users, messages, fit the conditions specified. Earlier versions of the SDK contained String-based filters which are now replaced by type-safe filters. This guide aims to explain the different types of filters and how to use them. +### Types Of Filters +#### Filter.equal + +The 'equal' filter gets the objects where the given key has the specified value. + +```dart +Filter.equal('type', 'messaging'), +``` + +#### Filter.notEqual + +The 'notEqual' filter gets the objects where the given key does not have the specified value. + +```dart +Filter.notEqual('type', 'messaging'), +``` + +#### Filter.greater + +The 'greater' filter gets the objects where the given key has a higher value than the specified value. + +```dart +Filter.greater('count', 5), +``` + +#### Filter.greaterOrEqual + +The 'greaterOrEqual' filter gets the objects where the given key has an equal or higher value than the specified value. + +```dart +Filter.greaterOrEqual('count', 5), +``` + +#### Filter.less + +The 'less' filter gets the objects where the given key has a lesser value than the specified value. + +```dart +Filter.less('count', 5), +``` + +#### Filter.lessOrEqual + +The 'lessOrEqual' filter gets the objects where the given key has a lesser or equal value than the specified value. + +```dart +Filter.lessOrEqual('count', 5), +``` + +#### Filter.in_ + +The 'in_' filter allows getting objects where the key matches any in a specified array. + +```dart +Filter.in_('members', [user.id]) +``` + +:::note +Since 'in' is a keyword in Dart, the filter has an underscore added. This does not apply to the 'notIn' +keyword. +::: + +#### Filter.notIn + +The 'notIn' filter allows getting objects where the key matches none in a specified array. + +```dart +Filter.notIn('members', [user.id]) +``` + +#### Filter.query + +Matches values by performing text search with the specified value. + +```dart +Filter.query('name', 'demo') +``` + +#### Filter.autoComplete + +Matches values with the specified prefix. + +```dart +Filter.autoComplete('name', 'demo') +``` + +#### Filter.exists + +Matches values that exist/don't exist based on the specified boolean value. + +```dart +Filter.exists('name', true) +``` + +### Group Queries + +#### FilterOperator.and + +The 'and' operator combines multiple queries. + +```dart +final filter = Filter.and([ + Filter.equal('type', 'messaging'), + Filter.in_('members', [user.id]) +]) +``` + +#### FilterOperator.or + +Combines the provided filters and matches the values matched by at least one of the filters. + +```dart +final filter = Filter.or([ + Filter.in_('bannedUsers', [user.id]), + Filter.in_('shadowBannedUsers', [user.id]) +]) +``` + +#### FilterOperator.nor + +Combines the provided filters and matches the values not matched by all the filters. + +```dart +final filter = Filter.nor([ + Filter.in_('bannedUsers', [user.id]), + Filter.in_('shadowBannedUsers', [user.id]) +]) +``` From 977a6fdc7d9dea613760d8f62b25845442c7d8f6 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 12 Aug 2021 18:56:58 +0530 Subject: [PATCH 3/6] Update docusaurus/docs/Flutter/guides/understanding_filters.mdx Co-authored-by: Gordon Hayes --- docusaurus/docs/Flutter/guides/understanding_filters.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/docs/Flutter/guides/understanding_filters.mdx b/docusaurus/docs/Flutter/guides/understanding_filters.mdx index 8a6fc925..d4ecf94c 100644 --- a/docusaurus/docs/Flutter/guides/understanding_filters.mdx +++ b/docusaurus/docs/Flutter/guides/understanding_filters.mdx @@ -85,7 +85,7 @@ Filter.notIn('members', [user.id]) #### Filter.query -Matches values by performing text search with the specified value. +The 'query' filter matches values by performing text search with the specified value. ```dart Filter.query('name', 'demo') From 1c846b4da7df6174171e44e157b129e00824817a Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 12 Aug 2021 18:57:04 +0530 Subject: [PATCH 4/6] Update docusaurus/docs/Flutter/guides/understanding_filters.mdx Co-authored-by: Gordon Hayes --- docusaurus/docs/Flutter/guides/understanding_filters.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/docs/Flutter/guides/understanding_filters.mdx b/docusaurus/docs/Flutter/guides/understanding_filters.mdx index d4ecf94c..a88f371c 100644 --- a/docusaurus/docs/Flutter/guides/understanding_filters.mdx +++ b/docusaurus/docs/Flutter/guides/understanding_filters.mdx @@ -93,7 +93,7 @@ Filter.query('name', 'demo') #### Filter.autoComplete -Matches values with the specified prefix. +The 'autoComplete' filter matches values with the specified prefix. ```dart Filter.autoComplete('name', 'demo') From c3444fe4915b6344cad4b6416a56f36d0e2787f1 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 12 Aug 2021 18:57:10 +0530 Subject: [PATCH 5/6] Update docusaurus/docs/Flutter/guides/understanding_filters.mdx Co-authored-by: Gordon Hayes --- docusaurus/docs/Flutter/guides/understanding_filters.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/docs/Flutter/guides/understanding_filters.mdx b/docusaurus/docs/Flutter/guides/understanding_filters.mdx index a88f371c..e7c288b4 100644 --- a/docusaurus/docs/Flutter/guides/understanding_filters.mdx +++ b/docusaurus/docs/Flutter/guides/understanding_filters.mdx @@ -101,7 +101,7 @@ Filter.autoComplete('name', 'demo') #### Filter.exists -Matches values that exist/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 Filter.exists('name', true) From a928bea12504168c935d899c503dfcdd29490d54 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 12 Aug 2021 19:00:54 +0530 Subject: [PATCH 6/6] added new guide --- docusaurus/docs/Flutter/guides/understanding_filters.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docusaurus/docs/Flutter/guides/understanding_filters.mdx b/docusaurus/docs/Flutter/guides/understanding_filters.mdx index e7c288b4..9d169a80 100644 --- a/docusaurus/docs/Flutter/guides/understanding_filters.mdx +++ b/docusaurus/docs/Flutter/guides/understanding_filters.mdx @@ -109,7 +109,7 @@ Filter.exists('name', true) ### Group Queries -#### FilterOperator.and +#### Filter.and The 'and' operator combines multiple queries. @@ -120,7 +120,7 @@ final filter = Filter.and([ ]) ``` -#### FilterOperator.or +#### Filter.or Combines the provided filters and matches the values matched by at least one of the filters. @@ -131,7 +131,7 @@ final filter = Filter.or([ ]) ``` -#### FilterOperator.nor +#### Filter.nor Combines the provided filters and matches the values not matched by all the filters.