Deleting Single Object¶
Method¶
Future<int> Backendless.data.of("TABLE-NAME").remove({Map entity, String whereClause});
Future<int> Backendless.data.withClass<E>().remove({E entity, String whereClause});
where:
Argument | Description |
---|---|
TABLE-NAME |
Name of the table where the object represented by Map will be deleted from. There must be objectId property in the map. The value of the property identifies the object which will be deleted. |
E |
Dart class of the data object to delete. |
entity |
Dart object to delete. Must contain the objectId property which identifies the object in the database. |
Return Value¶
The timestamp when the server-side removed the object from the data store.
Example¶
¶
void deleteContact() { Map contact = { "name": "Jack Daniels", "age": 147, "phone": "777-777-777", "title": "Favorites", }; Backendless.data.of("Contact").save(contact).then((savedContact) { // now delete the saved object Backendless.data.of("Contact").remove(entity: savedContact); }); }
Consider the following class:
The following code saves a new instance of the Contact class and subsequently updates it:
import 'package:backendless_sdk/backendless_sdk.dart'; @reflector class Contact { String objectId; String name; int age; String phone; String title; }
void deleteContact() { Contact contact = Contact() ..name = "Jack Daniels" ..age = 147 ..phone = "777-777-777" ..title = "Favorites"; Backendless.data.withClass<Contact>().save(contact).then((savedContact) { // now delete the saved object Backendless.data.withClass<Contact>().remove(entity: savedContact); }); }