-
Notifications
You must be signed in to change notification settings - Fork 0
Basic Conditions
Conditions, or instances of the StackBaseCondition class, are filters that refine results when searching for rows with certain traits. Using conditions allows for a large table with many rows to return a small target segment that contains records useful to the client. Conditions are necessary in order to design a scalable backend.
Declaration
+(instancetype) columnWithName:(NSString *)columnName isEqualTo:(id)value;Example
//get the first 3 rows where column 'id' is equal to 10
[weakSelf.table getFirst:3
rowsWhere:[StackBaseCondition columnWithName:@"id" isEqualTo:@10]
completionBlock:^(BOOL success, NSString *responseMessage, NSArray<NSDictionary *> *responseTable) {
for(NSDictionary *row in responseTable){
NSLog(@"row %ld: %@", ([responseTable indexOfObject:row] + 1), row);
}
}];Declaration
+(instancetype) columnWithName:(NSString *)columnName isNotEqualTo:(id)value;Example
//get the first 3 rows where column 'Name' is not equal to 'Jake'
[weakSelf.table getFirst:3
rowsWhere:[StackBaseCondition columnWithName:@"Name" isNotEqualTo:@"Jake"]
completionBlock:^(BOOL success, NSString *responseMessage, NSArray<NSDictionary *> *responseTable) {
for(NSDictionary *row in responseTable){
NSLog(@"row %ld: %@", ([responseTable indexOfObject:row] + 1), row);
}
}];Declaration
+(instancetype) columnWithName:(NSString *)columnName isGreaterThan:(NSNumber *)value;Example
//get the first 4 rows where column 'id' is greater than 10
[weakSelf.table getFirst:4
rowsWhere:[StackBaseCondition columnWithName:@"id" isGreaterThan:@10]
completionBlock:^(BOOL success, NSString *responseMessage, NSArray<NSDictionary *> *responseTable) {
for(NSDictionary *row in responseTable){
NSLog(@"row %ld: %@", ([responseTable indexOfObject:row] + 1), row);
}
}];Declaration
+(instancetype) columnWithName:(NSString *)columnName isLessThan:(NSNumber *)value;Example
//get the first 4 rows where column 'id' is less than 10
[weakSelf.table getFirst:4
rowsWhere:[StackBaseCondition columnWithName:@"id" isLessThan:@10]
completionBlock:^(BOOL success, NSString *responseMessage, NSArray<NSDictionary *> *responseTable) {
for(NSDictionary *row in responseTable){
NSLog(@"row %ld: %@", ([responseTable indexOfObject:row] + 1), row);
}
}];Declaration
+(instancetype) columnWithName:(NSString *)columnName startsWith:(NSString *)value;Example
//get the first 3 rows where the column 'Name' starts with the phrase 'Chri'
[weakSelf.table getFirst:3
rowsWhere:[StackBaseCondition columnWithName:@"Name" startsWith:@"Chri"]
completionBlock:^(BOOL success, NSString *responseMessage, NSArray<NSDictionary *> *responseTable) {
for(NSDictionary *row in responseTable){
NSLog(@"row %ld: %@", ([responseTable indexOfObject:row] + 1), row);
}
}];Declaration
+(instancetype) columnWithName:(NSString *)columnName matchesOneOfTheseValues:(NSArray *)values;Example
//get the first 3 rows where the column 'id' is equal to 1, 3, or 5
[weakSelf.table getFirst:3
rowsWhere:[StackBaseCondition columnWithName:@"id" matchesOneOfTheseValues:@[@1, @3, @5]]
completionBlock:^(BOOL success, NSString *responseMessage, NSArray<NSDictionary *> *responseTable) {
for(NSDictionary *row in responseTable){
NSLog(@"row %ld: %@", ([responseTable indexOfObject:row] + 1), row);
}
}];Declaration
+(instancetype) columnWithName:(NSString *)columnName doesNotMatchAnyOfTheseValues:(NSArray *)values;Example
//get the first 3 rows where the column 'Name' isn't equal to 'Dave' or 'John'
[weakSelf.table getFirst:3
rowsWhere:[StackBaseCondition columnWithName:@"Name" doesNotMatchAnyOfTheseValues:@[@"Dave", @"John"]]
completionBlock:^(BOOL success, NSString *responseMessage, NSArray<NSDictionary *> *responseTable) {
for(NSDictionary *row in responseTable){
NSLog(@"row %ld: %@", ([responseTable indexOfObject:row] + 1), row);
}
}];When passing numeric values into rows (@"example_numeric_field" : @4) or conditions ([StackBaseCondition columnWithName:@"id" isEqualTo:@1]), the numbers must be formatted as NSNumbers or be prefixed with '@' in order to be processed by the backend.
Intro
Managing Tables
Managing Columns
Managing Rows
Conditions
Going Forward