Objective-C Client Reference
Class PIOBigDB
Language: Objective-C
The BigDB service.
This class is used to create, load, and delete database objects. All database objects are stored in tables and have a unique key. You can set up tables in your admin panel, and you can also set up indexes there for when you want to load objects by properties or ranges of properties. Please note that all methods are asynchronous and any handling of results have to be done in a callback. If you don't care about the results of a method call, typically for create or delete functions, you can just pass in a null callback.
Here's how to store and update an object:
This is how you load an object:
In case you always want to modify an object, you can use the LoadOrCreate method to ensure you get an object back:
BigDB also supports indexes for retrieving objects by a specific property, a range of properties, or to sort objects by properties. Indexes need to be set up in the admin panel for each table, each index needs a name, and a list of properties, and for each property you also need to specify a sort order.
Imagine that we have objects that look like this:
That we have defined an index called "ByUsername" that looks like this: {Property:"username", Type:String, Order:Ascending}
And an index called "ByCreated" that looks like this: {Property:"created", Type:Datetime, Order:Descending}
Then we can do lookups like these:
BigDB also supports compound indexes, that is indexes with more than one property. Given our example object above, we can create an index called "ByLocationAgeCreated" that looks like this: {Property:"location", Type:String, Order:Ascending} {Property:"age", Type:Integer, Order:Ascending} {Property:"created", Type:Datetime, Order:Descending}
With this index, we can then lookup on either location, or location and age, or location and age and created. If we use more than one property in the lookup, we can only specify the range for the last one, the preceding ones have to be fixed and are sent in via the path parameter.
Finally, deleting objects is as easy as calling the DeleteKeys method, or DeleteRange if you want to delete by an index.
Methods | |||
---|---|---|---|
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
createObjectWithKey:inTable:object:successBlock:
Creates a new database object in the given table with the specified key. If no key is specified (null), the object will receive an autogenerated id.
Arguments
NSString* | key |
NSString* | table |
PIODatabaseObject* | object |
void(^)(PIODatabaseObject*created) | successBlock |
createObjectWithKey:inTable:object:successBlock:errorBlock:
Creates a new database object in the given table with the specified key. If no key is specified (null), the object will receive an autogenerated id.
Arguments
NSString* | key |
NSString* | table |
PIODatabaseObject* | object |
void(^)(PIODatabaseObject*created) | successBlock |
void(^)(PIOError*error) | errorBlock |
deleteKeys:fromTable:successBlock:
Delete a set of database objects from a table.
Arguments
NSArray* | keys |
NSString* | table |
void(^)(void) | successBlock |
deleteKeys:fromTable:successBlock:errorBlock:
Delete a set of database objects from a table.
Arguments
NSArray* | keys |
NSString* | table |
void(^)(void) | successBlock |
void(^)(PIOError*error) | errorBlock |
deleteRangeFromTable:index:indexPath:start:stop:successBlock:
Delete a range of database objects from a table using an index.
Arguments
NSString* | table |
NSString* | index |
NSArray* | indexPath |
id | start |
id | stop |
void(^)(void) | successBlock |
deleteRangeFromTable:index:indexPath:start:stop:successBlock:errorBlock:
Delete a range of database objects from a table using an index.
Arguments
NSString* | table |
NSString* | index |
NSArray* | indexPath |
id | start |
id | stop |
void(^)(void) | successBlock |
void(^)(PIOError*error) | errorBlock |
loadMyPlayerObjectWithSuccessBlock:
Loads the database object corresponding to the player from the PlayerObjects table.
Arguments
void(^)(PIODatabaseObject*playerObject) | successBlock |
loadMyPlayerObjectWithSuccessBlock:errorBlock:
Loads the database object corresponding to the player from the PlayerObjects table.
Arguments
void(^)(PIODatabaseObject*playerObject) | successBlock |
void(^)(PIOError*error) | errorBlock |
loadObjectsWithKeys:fromTable:successBlock:
Loads the database objects with the given keys from the given table.
Arguments
NSArray* | keys |
NSString* | table |
void(^)(NSArray*objects) | successBlock |
loadObjectsWithKeys:fromTable:successBlock:errorBlock:
Loads the database objects with the given keys from the given table.
Arguments
NSArray* | keys |
NSString* | table |
void(^)(NSArray*objects) | successBlock |
void(^)(PIOError*error) | errorBlock |
loadObjectWithKey:fromTable:successBlock:
Load the database object with the given key from the given table.
Arguments
NSString* | key |
NSString* | table |
void(^)(PIODatabaseObject*object) | successBlock |
loadObjectWithKey:fromTable:successBlock:errorBlock:
Load the database object with the given key from the given table.
Arguments
NSString* | key |
NSString* | table |
void(^)(PIODatabaseObject*object) | successBlock |
void(^)(PIOError*error) | errorBlock |
loadOrCreateObjectsWithKeys:fromTable:successBlock:
Loads or creates database objects with the given keys from the given table. New objects are created if there are no existing objects for the given keys.
Arguments
NSArray* | keys |
NSString* | table |
void(^)(NSArray*objects) | successBlock |
loadOrCreateObjectsWithKeys:fromTable:successBlock:errorBlock:
Loads or creates database objects with the given keys from the given table. New objects are created if there are no existing objects for the given keys.
Arguments
NSArray* | keys |
NSString* | table |
void(^)(NSArray*objects) | successBlock |
void(^)(PIOError*error) | errorBlock |
loadOrCreateObjectWithKey:fromTable:successBlock:
Loads or creates the database object with the given key from the given table.
Arguments
NSString* | key |
NSString* | table |
void(^)(PIODatabaseObject*object) | successBlock |
loadOrCreateObjectWithKey:fromTable:successBlock:errorBlock:
Loads or creates the database object with the given key from the given table.
Arguments
NSString* | key |
NSString* | table |
void(^)(PIODatabaseObject*object) | successBlock |
void(^)(PIOError*error) | errorBlock |
loadRangeFromTable:index:indexPath:start:stop:limit:successBlock:
Load a range of database objects from a table using the specified index.
Arguments
NSString* | table |
NSString* | index |
NSArray* | indexPath |
id | start |
id | stop |
int | limit |
void(^)(NSArray*objects) | successBlock |
loadRangeFromTable:index:indexPath:start:stop:limit:successBlock:errorBlock:
Load a range of database objects from a table using the specified index.
Arguments
NSString* | table |
NSString* | index |
NSArray* | indexPath |
id | start |
id | stop |
int | limit |
void(^)(NSArray*objects) | successBlock |
void(^)(PIOError*error) | errorBlock |
loadSingleFromTable:index:indexValue:successBlock:
Load a database object from a table using the specified index.
Arguments
NSString* | table |
NSString* | index |
NSArray* | indexValue |
void(^)(PIODatabaseObject*object) | successBlock |
loadSingleFromTable:index:indexValue:successBlock:errorBlock:
Load a database object from a table using the specified index.
Arguments
NSString* | table |
NSString* | index |
NSArray* | indexValue |
void(^)(PIODatabaseObject*object) | successBlock |
void(^)(PIOError*error) | errorBlock |
saveChanges:useOptimisticLocks:fullOverwrite:successBlock:
Save changes to one or more database objects in one go.
Arguments
NSArray* | objects |
BOOL | useOptimisticLocks |
BOOL | fullOverwrite |
void(^)(void) | successBlock |
saveChanges:useOptimisticLocks:fullOverwrite:successBlock:errorBlock:
Save changes to one or more database objects in one go.
Arguments
NSArray* | objects |
BOOL | useOptimisticLocks |
BOOL | fullOverwrite |
void(^)(void) | successBlock |
void(^)(PIOError*error) | errorBlock |