11part of 'appwrite.dart' ;
22
3-
43/// Helper class to generate query strings.
54class Query {
65 final String method;
@@ -10,15 +9,13 @@ class Query {
109 Query ._(this .method, [this .attribute = null , this .values = null ]);
1110
1211 Map <String , dynamic > toJson () {
13- final map = < String , dynamic > {
14- 'method' : method,
15- };
12+ final map = < String , dynamic > {'method' : method};
1613
17- if (attribute != null ) {
14+ if (attribute != null ) {
1815 map['attribute' ] = attribute;
1916 }
20-
21- if (values != null ) {
17+
18+ if (values != null ) {
2219 map['values' ] = values is List ? values : [values];
2320 }
2421
@@ -29,7 +26,7 @@ class Query {
2926 String toString () => jsonEncode (toJson ());
3027
3128 /// Filter resources where [attribute] is equal to [value] .
32- ///
29+ ///
3330 /// [value] can be a single value or a list. If a list is used
3431 /// the query will return resources where [attribute] is equal
3532 /// to any of the values in the list.
@@ -61,10 +58,12 @@ class Query {
6158 Query ._('search' , attribute, value).toString ();
6259
6360 /// 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 ();
6563
6664 /// 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 ();
6867
6968 /// Filter resources where [attribute] is between [start] and [end] (inclusive).
7069 static String between (String attribute, dynamic start, dynamic end) =>
@@ -84,40 +83,52 @@ class Query {
8483 Query ._('contains' , attribute, value).toString ();
8584
8685 static String or (List <String > queries) =>
87- Query ._('or' , null , queries.map ((query) => jsonDecode (query)).toList ()).toString ();
86+ Query ._(
87+ 'or' ,
88+ null ,
89+ queries.map ((query) => jsonDecode (query)).toList (),
90+ ).toString ();
8891
8992 static String and (List <String > queries) =>
90- Query ._('and' , null , queries.map ((query) => jsonDecode (query)).toList ()).toString ();
93+ Query ._(
94+ 'and' ,
95+ null ,
96+ queries.map ((query) => jsonDecode (query)).toList (),
97+ ).toString ();
9198
9299 /// Specify which attributes should be returned by the API call.
93100 static String select (List <String > attributes) =>
94101 Query ._('select' , null , attributes).toString ();
95102
96103 /// Sort results by [attribute] ascending.
97- static String orderAsc (String attribute) => Query ._('orderAsc' , attribute).toString ();
104+ static String orderAsc (String attribute) =>
105+ Query ._('orderAsc' , attribute).toString ();
98106
99107 /// Sort results by [attribute] descending.
100- static String orderDesc (String attribute) => Query ._('orderDesc' , attribute).toString ();
108+ static String orderDesc (String attribute) =>
109+ Query ._('orderDesc' , attribute).toString ();
101110
102111 /// Return results before [id] .
103- ///
112+ ///
104113 /// Refer to the [Cursor Based Pagination] (https://appwrite.io/docs/pagination#cursor-pagination)
105114 /// docs for more information.
106- static String cursorBefore (String id) => Query ._('cursorBefore' , null , id).toString ();
115+ static String cursorBefore (String id) =>
116+ Query ._('cursorBefore' , null , id).toString ();
107117
108118 /// Return results after [id] .
109- ///
119+ ///
110120 /// Refer to the [Cursor Based Pagination] (https://appwrite.io/docs/pagination#cursor-pagination)
111121 /// docs for more information.
112- static String cursorAfter (String id) => Query ._('cursorAfter' , null , id).toString ();
122+ static String cursorAfter (String id) =>
123+ Query ._('cursorAfter' , null , id).toString ();
113124
114125 /// Return only [limit] results.
115126 static String limit (int limit) => Query ._('limit' , null , limit).toString ();
116127
117128 /// Return results from [offset] .
118- ///
129+ ///
119130 /// Refer to the [Offset Pagination] (https://appwrite.io/docs/pagination#offset-pagination)
120131 /// docs for more information.
121- static String offset (int offset) => Query ._( 'offset' , null , offset). toString ();
122-
123- }
132+ static String offset (int offset) =>
133+ Query ._( 'offset' , null , offset). toString ();
134+ }
0 commit comments