Search code examples
ember.jsember-data

Ember-data update a record


I can't find anything anywhere, but it is possible to modify a record inside the store with ember-data ?

I know there is store.createRecord( 'user', { name: bob}); But how can I do to be able to modify a specific record ?

Like this : store.updateRecord( 'user', recordToModify, newData) ?

Is there anything already available by ember-data or I should just write it by myself ?


Solution

  • DS.Model provides a save method:

    recordToModify.set('someAttribute', 'someValue');
    
    recordToModify.save().then(function() {
      // Success callback
    }, function() {
      // Error callback
    });