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:
List<Map<String, dynamic>> persons = new List(); Map<String, dynamic> person1 = { "age": 24, "name": "Joe", }; persons.add(person1); Map<String, dynamic> person2 = { "age": 34, "name": "Betty", }; persons.add(person2); Backendless.data.of("Person").create(persons).then((response) { print("Objects have been saved"); });
The result of running the sample above is two objects saved in the database:
Method¶
Future<List<String>> Backendless.data.of("TABLE-NAME").create(List<Map> objects);
Future<List<String>> Backendless.data.withClass<E>().create(List<E> objects);
where:
Argument | Description |
---|---|
TABLE-NAME |
Name of the table where the objects expressed via Map instances will be saved. |
E |
Dart class of the data objects to save in the database. |
objects |
A collection of Dart objects to save in the database, must be of type E or Map (depending on the method used). |
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 must not have
objectId
. If there is a value in theobjectId
property in a provided object, the object is ignored by the server. - 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.