1
1
part of 'dart_appwrite.dart' ;
2
2
3
-
4
3
/// Helper class to generate query strings.
5
4
class Query {
6
5
final String method;
@@ -10,15 +9,13 @@ class Query {
10
9
Query ._(this .method, [this .attribute = null , this .values = null ]);
11
10
12
11
Map <String , dynamic > toJson () {
13
- final map = < String , dynamic > {
14
- 'method' : method,
15
- };
12
+ final map = < String , dynamic > {'method' : method};
16
13
17
- if (attribute != null ) {
14
+ if (attribute != null ) {
18
15
map['attribute' ] = attribute;
19
16
}
20
-
21
- if (values != null ) {
17
+
18
+ if (values != null ) {
22
19
map['values' ] = values is List ? values : [values];
23
20
}
24
21
@@ -29,7 +26,7 @@ class Query {
29
26
String toString () => jsonEncode (toJson ());
30
27
31
28
/// Filter resources where [attribute] is equal to [value] .
32
- ///
29
+ ///
33
30
/// [value] can be a single value or a list. If a list is used
34
31
/// the query will return resources where [attribute] is equal
35
32
/// to any of the values in the list.
@@ -61,10 +58,12 @@ class Query {
61
58
Query ._('search' , attribute, value).toString ();
62
59
63
60
/// Filter resources where [attribute] is null.
64
- static String isNull (String attribute) => Query ._('isNull' , attribute).toString ();
61
+ static String isNull (String attribute) =>
62
+ Query ._('isNull' , attribute).toString ();
65
63
66
64
/// Filter resources where [attribute] is not null.
67
- static String isNotNull (String attribute) => Query ._('isNotNull' , attribute).toString ();
65
+ static String isNotNull (String attribute) =>
66
+ Query ._('isNotNull' , attribute).toString ();
68
67
69
68
/// Filter resources where [attribute] is between [start] and [end] (inclusive).
70
69
static String between (String attribute, dynamic start, dynamic end) =>
@@ -83,41 +82,51 @@ class Query {
83
82
static String contains (String attribute, dynamic value) =>
84
83
Query ._('contains' , attribute, value).toString ();
85
84
86
- static String or (List <String > queries) =>
87
- Query ._('or' , null , queries.map ((query) => jsonDecode (query)).toList ()).toString ();
85
+ static String or (List <String > queries) => Query ._(
86
+ 'or' ,
87
+ null ,
88
+ queries.map ((query) => jsonDecode (query)).toList (),
89
+ ).toString ();
88
90
89
- static String and (List <String > queries) =>
90
- Query ._('and' , null , queries.map ((query) => jsonDecode (query)).toList ()).toString ();
91
+ static String and (List <String > queries) => Query ._(
92
+ 'and' ,
93
+ null ,
94
+ queries.map ((query) => jsonDecode (query)).toList (),
95
+ ).toString ();
91
96
92
97
/// Specify which attributes should be returned by the API call.
93
98
static String select (List <String > attributes) =>
94
99
Query ._('select' , null , attributes).toString ();
95
100
96
101
/// Sort results by [attribute] ascending.
97
- static String orderAsc (String attribute) => Query ._('orderAsc' , attribute).toString ();
102
+ static String orderAsc (String attribute) =>
103
+ Query ._('orderAsc' , attribute).toString ();
98
104
99
105
/// Sort results by [attribute] descending.
100
- static String orderDesc (String attribute) => Query ._('orderDesc' , attribute).toString ();
106
+ static String orderDesc (String attribute) =>
107
+ Query ._('orderDesc' , attribute).toString ();
101
108
102
109
/// Return results before [id] .
103
- ///
110
+ ///
104
111
/// Refer to the [Cursor Based Pagination] (https://appwrite.io/docs/pagination#cursor-pagination)
105
112
/// docs for more information.
106
- static String cursorBefore (String id) => Query ._('cursorBefore' , null , id).toString ();
113
+ static String cursorBefore (String id) =>
114
+ Query ._('cursorBefore' , null , id).toString ();
107
115
108
116
/// Return results after [id] .
109
- ///
117
+ ///
110
118
/// Refer to the [Cursor Based Pagination] (https://appwrite.io/docs/pagination#cursor-pagination)
111
119
/// docs for more information.
112
- static String cursorAfter (String id) => Query ._('cursorAfter' , null , id).toString ();
120
+ static String cursorAfter (String id) =>
121
+ Query ._('cursorAfter' , null , id).toString ();
113
122
114
123
/// Return only [limit] results.
115
124
static String limit (int limit) => Query ._('limit' , null , limit).toString ();
116
125
117
126
/// Return results from [offset] .
118
- ///
127
+ ///
119
128
/// Refer to the [Offset Pagination] (https://appwrite.io/docs/pagination#offset-pagination)
120
129
/// docs for more information.
121
- static String offset (int offset) => Query ._( 'offset' , null , offset). toString ();
122
-
123
- }
130
+ static String offset (int offset) =>
131
+ Query ._( 'offset' , null , offset). toString ();
132
+ }
0 commit comments