Skip to content

Deleting Single Object

Backendless.Data.of( "TABLE-NAME" ).remove( { objectId:"XXXX-XXXX-XXXX-XXXX" } )
 .then( function( timestamp ) {
  })
 .catch( function( error ) {
  });
function DataTypeX() {
  // define properties of the class here
}
Backendless.Data.of( DataTypeX ).remove( dataTypeXInstance )
 .then( function( timestamp ) {
  })
 .catch( function( error ) {
  });

where:

Argument                Description
DataTypeX function/class identifying the table where the object will be deleted.
"TABLE-NAME" name of the table where the object will be deleted.
dataTypeXInstance object to delete. Must contain the objectId property assigned by Backendless.

Important

The remove method argument must be an object with the objectId property containing a value assigned by Backendless. The object must be stored in the data table identified in the of() function.

Return Value

Returns a time stamp when the server-side removed the object from the data store

Example

// to delete an object on the server, it must have the "objectId"
// property with a value assigned by Backendless
var contact = {
    objectId:"XXXX-XXXX-XXXX-XXXXX",
    name:"Jack Daniels",
    age:147,
    phone:"777-777-777",
    title:"Favorites"
}

Backendless.Data.of( "Contact" ).remove( contact )
  .then( function( timestamp ) {
      console.log( "Contact instance has been deleted" );
    })
  .catch( function( error ) {
      console.log( "an error has occurred " + error.message );
    });
Consider the following class:
function Contact(args) {
    args = args || {};
    this.name = args.name || "";
    this.age = args.age || "";
    this.phone = args.phone || "";
    this.title = args.title || "";
}
The following code deletes a Contact object:
// do not forget to initialize the app with Backendless.initApp( appId, jsAPIKey );

// to delete an object stored on the server, it must have the "objectId"
// property with a value assigned by Backendless
var contactObject = new Contact( {
    objectId: "XXXXX-XXXXX-XXXXXX-XXXXX",
    name: "James Bond",
    age: 45,
    phone: "1-800-JAMESBOND",
    title: "chief spying officer"
});

Backendless.Data.of( Contact ).remove( contact )
  .then( function( timestamp ) {
      console.log( "Contact object has been deleted" );
    })
  .catch( function( error ) {
      console.log( "an error has occurred " + error.message );
    });