Saving Single Object¶
Method¶
Future<Map> Backendless.data.of("TABLE-NAME").save(Map entity);
Future<E> Backendless.data.withClass<E>().save(E entity);
where:
Argument | Description |
---|---|
TABLE-NAME |
Name of the table where the object represented by Map will be saved. |
E |
Dart class of the data object to save. |
entity |
Dart object to persist, must be of type E or Map (depending on the method used). |
Return Value¶
The saved object of type E or Map.
Example¶
void saveNewContact() { Map contact = { "name": "Jack Daniels", "age": 147, "phone": "777-777-777", "title": "Favorites", }; Backendless.data.of( "Contact" ).save(contact).then((response) { // new Contact instance has been saved }); }
import 'package:backendless_sdk/backendless_sdk.dart'; @reflector class Contact { String objectId; String name; int age; String phone; String title; } void saveNewContact() { Contact contact = Contact() ..name = "Jack Daniels" ..age = 147 ..phone = "777-777-777" ..title = "Favorites"; Backendless.data.withClass<Contact>().save(contact).then((response) { // new Contact instance has been saved }); }