Internet Explorer 8

Instantiating the Store

In Ember Data, the store is responsible for managing the lifecycle of
your models. Every time you need a model or a collection of models,
you'll ask the store for it.

To create a store, you don't need to do anything. Just by loading the
Ember Data library, all of the routes and controllers in your
application will get a new store property. This property is an
instance of DS.Store that will be shared across all of the routes and
controllers in your app.

Defining Your Models

First thing's first: tell Ember Data about the models in your
application. For example, imagine we're writing a blog reader app.
Here's what your model definition would look like if you're using
globals (that is, not something like Ember App Kit or ember-cli):

A Brief Note on Adapters

Without immediately diving in to the depths of the architecture, one
thing you should know is that Ember Data uses an object called an
adapter to know how to talk to your server.

An adapter is just an object that knows how to translate requests from
Ember Data into requests on your server. For example, if I ask the Ember
Data store for a record of type person with an ID of 123, the
adapter translates that into an XHR request to (for example)
api.example.com/v3/person/123.json.

By default, Ember Data will use the RESTAdapter, which adheres to a
set of RESTful JSON conventions.

Ember Data also ships with the FixtureAdapter, useful for testing and
prototyping before you have a server, and the ActiveModelAdapter,
which is designed to work out-of-the-box with the
ActiveModel::Serializers
gem for Rails.

To learn more about adapters, including what conventions the
RESTAdapter follows and how to build your own, see the Ember.js
Guides: Connecting to an HTTP
Server.

Fetching a Collection of Models

From your route or controller:

this.store.find('blogPost');

This returns a promise that resolves to the collection of records.

Fetching a Single Model

this.store.find('blogPost', 123);

This returns a promise that resolves to the requested record. If the
record can't be found or there was an error during the request, the
promise will be rejected.