createRecord

When the application initializes, Ember Data creates store, a local store object. this.store is the object that will create, retrieve, update, and delete all of the Tracker app’s model records. Ember injects the store object in all Routes, Controllers, and Components. In the scope of route methods, you have access to the store from this.

To create a record, you will call this.store.createRecord. This method expects two arguments: a model name, as a string, and record data, as an object.

Open app/routes/sightings.js. Delete your dummy sightings and create three new sighting records, each with a location value as a string and a sightedAt value as a new Date:

import Ember from 'ember'; export default Ember.Route.extend({ ...

Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.