Inherits from NSObject
Declared in DBTable.h

Overview

A collection of records that lets you query for existing records or insert new ones. You can get an instance using the getTable: or getTables: methods on DBDatastore.

In addition to querying and inserting records, you can also set custom conflict resolution rules.

When using the max and min resolution rules, values are compared as follows: integer, floating point, boolean, and date values are ordered by their numerical value. String, byte, and list values are lexicographically ordered. Integer and floating point values are compared to each other by casting to double, but boolean values are treated as a distinct type ordered before all other numbers. Other values of distinct types are ordered by type, in the order listed above. For example, all boolean values are ordered before all other numeric values, which in turn are ordered before all string values.

Tasks

  • + isValidId:

    Returns YES if tableId is a valid ID for a DBTable, or NO otherwise. IDs are case-sensitive, can be 1-64 characters long and may contain alphanumeric characters plus these punctuation characters: . - _ + / = IDs with a leading : are valid, but reserved for internal use. (Note that older SDKs limited these to 32 characters, so take care if your datastore needs to be accessed by legacy clients.)

  • – query:error:

    Returns records matching the provided filter, or all records if filter is nil.

  • – getRecord:error:

    Returns a record with the given recordId, or nil if that record doesn’t exist or an error occurred.

  • – getOrInsertRecord:fields:inserted:error:

    Returns a record with the given recordId (unmodified), or inserts a new record with the initial set of fields if it doesn’t exist already.

  • – insert:

    Insert a new record with the initial set of fields into this table with a unique record ID.

  • – setResolutionRule:forField:

    Sets pattern as the resolution pattern for conflicts involving the given fieldname. The new resolution rule will be applied when merging local changes with remote changes during a call to [DBDatastore sync:].

  •   tableId

    The ID of the table.

    property
  •   datastore

    The datastore that contains this table.

    property

Properties

datastore

@property (nonatomic, readonly) DBDatastore *datastore
Discussion

The datastore that contains this table.

Declared In

DBTable.h

tableId

@property (nonatomic, readonly) NSString *tableId
Discussion

The ID of the table.

Declared In

DBTable.h

Class Methods

isValidId:

+ (BOOL)isValidId:(NSString *)tableId
Discussion

Returns YES if tableId is a valid ID for a DBTable, or NO otherwise. IDs are case-sensitive, can be 1-64 characters long and may contain alphanumeric characters plus these punctuation characters: . - _ + / = IDs with a leading : are valid, but reserved for internal use. (Note that older SDKs limited these to 32 characters, so take care if your datastore needs to be accessed by legacy clients.)

Declared In

DBTable.h

Instance Methods

getOrInsertRecord:fields:inserted:error:

- (DBRecord *)getOrInsertRecord:(NSString *)recordId fields:(NSDictionary *)fields inserted:(BOOL *)inserted error:(DBError **)error
Discussion

Returns a record with the given recordId (unmodified), or inserts a new record with the initial set of fields if it doesn’t exist already.

Parameters

inserted

if provided, the BOOL pointed to by inserted will be set to YES if a new record was inserted, or NO otherwise.

Return Value

the record if it is present in the table or inserted, or nil if an error occurred.

Declared In

DBTable.h

getRecord:error:

- (DBRecord *)getRecord:(NSString *)recordId error:(DBError **)error
Discussion

Returns a record with the given recordId, or nil if that record doesn’t exist or an error occurred.

Declared In

DBTable.h

insert:

- (DBRecord *)insert:(NSDictionary *)fields
Discussion

Insert a new record with the initial set of fields into this table with a unique record ID.

Declared In

DBTable.h

query:error:

- (NSArray *)query:(NSDictionary *)filter error:(DBError **)error
Discussion

Returns records matching the provided filter, or all records if filter is nil.

Parameters

filter

For every key value pair in filter, the query will only return records where the field with the same name has the same value.

Declared In

DBTable.h

setResolutionRule:forField:

- (void)setResolutionRule:(DBResolutionRule)rule forField:(NSString *)field
Discussion

Sets pattern as the resolution pattern for conflicts involving the given fieldname. The new resolution rule will be applied when merging local changes with remote changes during a call to [DBDatastore sync:].

Declared In

DBTable.h