deleteRecord (store, type, snapshot) Promise
Implement this method in a subclass to handle the deletion of a record.
Sends a delete request for the record to the server.
Example
app/adapters/application.js
import DS from 'ember-data'; export default DS.Adapter.extend({ deleteRecord: function(store, type, snapshot) { var data = this.serialize(snapshot, { includeId: true }); var id = snapshot.id; return new Ember.RSVP.Promise(function(resolve, reject) { Ember.$.ajax({ type: 'DELETE', url: `/${type.modelName}/${id}`, dataType: 'json', data: data }).then(function(data) { Ember.run(null, resolve, data); }, function(jqXHR) { jqXHR.then = null; // tame jQuery's ill mannered promises Ember.run(null, reject, jqXHR); }); }); } });
Parameters:
-
store
DS.Store
-
type
DS.Model
- the DS.Model class of the record
-
snapshot
DS.Snapshot
Returns:
-
Promise
- promise
Please login to continue.