Reputation: 9013
I may be being daft but the Ember.js's Model section seems to really only cover GETing data from a REST server but not adding a new one or updating an existing one. I did notice the following:
store.push()
but the coverage is brief and the use case is not practical for most web applications. Can anyone suggest some other examples of adding or updating data using Ember Data's 1.0-beta codebase?
Upvotes: 2
Views: 5241
Reputation: 8584
The "Getting Started" section of the Ember guides has the basic info about creating and updating records.
http://emberjs.com/guides/getting-started/creating-a-new-model/
var post = this.store.createRecord('post'{ title : "My New Post"});
post.save();
http://emberjs.com/guides/getting-started/marking-a-model-as-complete-incomplete/
var post = this.get('content');
post.set("title", "My New Title");
post.save();
In both cases calling save()
on the model is what "commits" the changes. You can also call rollback()
if you want to revert.
Upvotes: 4