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