O'Reilly logo

Ember.js Web Development with Ember CLI by Suchit Puri

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with records

As we now have some understanding of how a store works, let's see how we can use the store to create and delete a record.

To create a new record, you can use the createRecord method present on the instance of DS.Store. In your controller or route, you can get the reference of the store object by calling this.store. Let's take a look at the following example, to know how to create a record of type book:

var book = this.store.createRecord('book',{
  title: "Ember.js Essentials",
  isbn: "ISBN1",
  pages: 180,
  description: "The Essentials required to master Ember.js"
});

As you may have figured out, the createRecordfunction takes in two arguments; the first one is the name of the model object you want to instantiate, which is book in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required