DS.Model#save()

save (options) Promise

Defined in addon/-private/system/model/model.js:704

Save the record and persist any changes to the record to an external source via the adapter.

Example

record.set('name', 'Tomster');
record.save().then(function() {
  // Success callback
}, function() {
  // Error callback
});

If you pass an object on the adapterOptions property of the options argument it will be passed to you adapter via the snapshot

record.save({ adapterOptions: { subscribe: false } });
app/adapters/post.js
import MyCustomAdapter from './custom-adapter';

export default MyCustomAdapter.extend({
  updateRecord: function(store, type, snapshot) {
    if (snapshot.adapterOptions.subscribe) {
      // ...
    }
    // ...
  }
});

Parameters:

options Object

Returns:

Promise
a promise that will be resolved when the adapter returns successfully or rejected if the adapter returns with an error.
doc_EmberJs
2016-11-30 16:50:13
Comments
Leave a Comment

Please login to continue.