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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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.