Skip to content

Column Groups

cmancushman edited this page Oct 28, 2017 · 6 revisions

Using Column Groups

When an instance of StackBaseTable is created with the 'connectToStackBaseTableWithName:' method, it organizes its tables into groups:

  • allColumns -- every column the table contains.

  • dateTypeColumns -- every date-time column the table contains.

  • textTypeColumnss -- every text column the table contains.

  • numericTypeColumns -- every numeric column the table contains.

The accessor methods StackBaseTable provides


Accessing All Columns

Declarations

-(NSArray<StackBaseColumn *> *)allColumns;
-(NSArray<NSString *> *)allColumnNames;

Example

NSArray *allColumns = [weakSelf.table allColumns];

Accessing All Date-Time Columns

Declarations

-(NSArray<StackBaseColumn *> *)dateTypeColumns;
-(NSArray<NSString *> *)dateTypeColumnNames;

Example

NSArray *dateTimeColumns = [weakSelf.table dateTypeColumns];

Accessing All Text Columns

Declarations

-(NSArray<StackBaseColumn *> *)textTypeColumns;
-(NSArray<NSString *> *)textTypeColumnNames;

Example

NSArray *textColumns = [weakSelf.table textTypeColumns];

Accessing All Numeric Columns

Declarations

-(NSArray<StackBaseColumn *> *)numericTypeColumns;
-(NSArray<NSString *> *)numericTypeColumnNames;

Example

NSArray *numericColumns = [weakSelf.table numericTypeColumns];

Checking if a Column Exists

Declarations

-(BOOL)columnExistsWithName:(NSString *)name;

Example

if([weakSelf.table columnExistsWithName:@"Name"]){
    
    NSLog(@"Column Exists!");
    
}

Utilizing Column Groups

Column groups can help make running commands more intuitive. They can be passed as search parameters for queries, or removed all at the same time.

Examples

[weakSelf.table getFirst:3 rowsWhere:[StackBaseCondition columnsWithNames:[weakSelf.table textTypeColumnNames] matchPhrase:@"donut"] completionBlock:^(BOOL success, NSString *responseMessage, NSArray<NSDictionary *> *responseTable) {
    
    for(NSDictionary *row in responseTable){
        
        NSLog(@"row %ld: %@", ([responseTable indexOfObject:row] + 1), row);
        
    }
    
}];
[weakSelf.table removeColumns:[weakSelf.table numericTypeColumns] completionBlock:^(BOOL success, NSString *responseMessage) {
    
    if(success){
        
        NSLog(@"Operation Successful.");
        
    }else{
        
        NSLog(@"Operation Unsuccessful: %@", responseMessage);
        
    }
    
}];

Clone this wiki locally