-
Notifications
You must be signed in to change notification settings - Fork 0
Ordering Results
cmancushman edited this page Oct 27, 2017
·
1 revision
Once you have constructed a robust condition to properly narrow query results, you may want your results to be ordered. Ordering your results can be useful in displaying search results that are the newest, most popular, or most relevant in some other metric to make your data more useful to the user.
Declaration
+(instancetype) condition:(StackBaseCondition *)condition1 isOrderedBy:(NSArray<NSString *> *)columnNames;Example
//get the first 3 rows where column 'id' is greater than 10, ordered by the 'id' column
StackBaseCondition *idIsBigEnough = [StackBaseCondition columnWithName:@"id" isGreaterThan:@10];
[weakSelf.table getFirst:3
rowsWhere:[StackBaseCondition condition:idIsBigEnough isOrderedBy:@[@"id"]]
completionBlock:^(BOOL success, NSString *responseMessage, NSArray<NSDictionary *> *responseTable) {
for(NSDictionary *row in responseTable){
NSLog(@"row %ld: %@", ([responseTable indexOfObject:row] + 1), row);
}
}];Intro
Managing Tables
Managing Columns
Managing Rows
Conditions
Going Forward