File tree 2 files changed +19
-17
lines changed
2 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -50,8 +50,8 @@ class _MyAppState extends State<MyApp> {
50
50
//getAllItems();
51
51
//getAllItemsByName();
52
52
//getSingleItem();
53
- // query();
54
- initUser ();
53
+ query ();
54
+ // initUser();
55
55
}
56
56
57
57
void getAllItemsByName () async {
@@ -87,18 +87,16 @@ class _MyAppState extends State<MyApp> {
87
87
}
88
88
89
89
void query () async {
90
- // Query for an object by name
91
90
var queryBuilder = QueryBuilder <DietPlan >(DietPlan ())
92
91
..greaterThan (DietPlan .FAT , 20 )
93
- ..limit (1 )
94
- ..skip (1 );
92
+ ..descending (DietPlan .FAT );
95
93
96
94
var response = await queryBuilder.query ();
97
95
98
96
if (response.success) {
99
- print (ApplicationConstants . APP_NAME + ": " + ((response.result as List <dynamic >).first as DietPlan ).toString ());
97
+ print ("Result: ${ ((response .result as List <dynamic >).first as DietPlan ).toString ()}" );
100
98
} else {
101
- print (ApplicationConstants . APP_NAME + ": " + response.exception.message);
99
+ print ("Result: ${ response .exception .message }" );
102
100
}
103
101
}
104
102
Original file line number Diff line number Diff line change @@ -41,19 +41,23 @@ class QueryBuilder<T extends ParseObject> {
41
41
_skip = skip;
42
42
}
43
43
44
- void where (int where){
44
+ void where (String where){
45
45
_where = where;
46
46
}
47
47
48
- void order ( int order){
48
+ void ascending ( String order){
49
49
_order = order;
50
50
}
51
51
52
- void keys (int keys){
52
+ void descending (String order){
53
+ _order = "-$order " ;
54
+ }
55
+
56
+ void keys (String keys){
53
57
_keys = keys;
54
58
}
55
59
56
- void include (int include){
60
+ void include (String include){
57
61
_include = include;
58
62
}
59
63
@@ -175,12 +179,12 @@ class QueryBuilder<T extends ParseObject> {
175
179
176
180
// ADD PARAMS
177
181
Map limiters = Map ();
178
- if (_where != null ) limiters['where' ] = where ;
179
- if (_order != null ) limiters["order" ] = order ;
180
- if (_limit != 0 ) limiters["limit" ] = limit ;
181
- if (_skip != 0 ) limiters["skip" ] = skip ;
182
- if (_keys != null ) limiters["keys" ] = keys ;
183
- if (_include != null ) limiters["include" ] = include ;
182
+ if (_where != null ) limiters['where' ] = _where ;
183
+ if (_order != null ) limiters["order" ] = _order ;
184
+ if (_limit != 0 ) limiters["limit" ] = _limit ;
185
+ if (_skip != 0 ) limiters["skip" ] = _skip ;
186
+ if (_keys != null ) limiters["keys" ] = _keys ;
187
+ if (_include != null ) limiters["include" ] = _include ;
184
188
query += getLimiters (limiters);
185
189
186
190
// -- TEST
You can’t perform that action at this time.
0 commit comments