Skip to content

Saving Multiple Objects

This API stores multiple objects in a data table with a single request. Consider the following example, it demonstrates an API call which saves two objects in the Person data table:

NSDictionary *person1 = @{@"age": @24, @"name": @"Joe"};
NSDictionary *person2 = @{@"age": @34, @"name": @"Betty"};

MapDrivenDataStore *dataStore = [ ofTable:@"Person"];
[dataStore createBulkWithEntities:@[person1, person2] responseHandler:^(NSArray *savedObjectIds) {
    NSLog(@"Objects have been saved: %@", savedObjectIds);
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
let person1 = ["age": 24, "name": "Joe"] as [String : Any]
let person2 = ["age": 34, "name": "Betty"] as [String : Any]

let dataStore ="Person")         
dataStore.createBulk(entities: [person1, person2], responseHandler: { savedObjectIds in
    print("Objects have been saved: \(savedObjectIds)")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")

The result of running the sample above is two objects saved in the database:


Available methods

- (void)createBulkWithEntities:(NSArray * _Nonnull)entities responseHandler:^(NSArray<NSString *> * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func createBulk(entities: [Any], responseHandler: (([String]) -> Void)!, errorHandler: ((Fault) -> Void)!)
- (void)createBulkWithEntities:(NSArra<NSDictionary<NSString *,id> *> * _Nonnull)entities responseHandler:^(NSArray<NSString *> * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func createBulk(entities: [[String : Any]], responseHandler: (([String]) -> Void)!, errorHandler: ((Fault) -> Void)!)


Argument                Description
entities objects to save in the database.
responseHandler a block (closure) to handle successful result of an asynchronous call.
errorHandler a block (closure) to handle fault result of an asynchronous call.

Return Value

The API returns a collection of object IDs for the objects created in the database. The order of  the objectId values in the response matches the order of the objects in the request.

The Backendless server implementation enforces the following rules:

  • All objects in the request must be of the same type.
  • Objects in the request may have different set of properties. If a column does not exist for a property, Backendless will dynamically create it, if the Dynamic Schema Definition configuration is enabled.
  • Objects in the request may have a unique objectId value that is not used in the database.
  • Maximum number of objects in a single request is 100 for Backendless Cloud. It is configurable for Backendless Pro and Managed Backendless.
  • A request will be rejected by the server, if there is no Create permission granted to the user identity/roles associated with the request.