O'Reilly logo

Mastering Ember.js by Mitchel Kelonye

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

Creating a data store

Applications that use Ember-data usually use a single storage repository that stores all records that are available to the application. This store is defined from the DS.Store class, as follows:

App.ApplicationStore = DS.Store.extend({
});

The preceding code is automatically executed by Ember.js, and so we do not need to do anything. Just like the router, this class is usually autoinstantiated and made accessible to all routes and controllers as a store property. Here's an example that demonstrates a route that accesses the application's store:

App.BooksRoute = Ember.Route.extend({
  model: function(){
    return this.store.find('book');
  }
   });

Do not worry about what this does. The important thing to learn from the preceding snippet ...

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