Ember Data — The Data Layer

JSON-API by Default, Pluggable Adapters

Ember Data — The Data Layer

Ember Data is Ember's official ORM-style data layer — models, store, relationships, and an identity map.

4 min read Level 2/5 #ember#ember-data#orm
What you'll learn
  • Recognize the store, model, adapter, and serializer parts
  • Install the ember-data package
  • Inject the store with the service decorator

Ember Data is the data layer that ships with every new Ember app. It gives you typed records, relationships, an identity map, and a clean separation between your domain models and your HTTP transport.

The Four Pieces

  • Store — the entry point, holds the identity map, hands out records.
  • Model — declares the shape of a record (@attr, @belongsTo, @hasMany).
  • Adapter — speaks HTTP, decides URLs, headers, and verbs.
  • Serializer — translates payloads into the internal format and back.

The default contract is JSON-API, but the adapter/serializer layer makes it pluggable.

Install

It comes preinstalled in modern Ember apps. If you need it manually:

ember install ember-data

Inject The Store

import Component from '@glimmer/component';
import { service } from '@ember/service';

export default class Posts extends Component {
  @service store;

  get posts() {
    return this.store.peekAll('post');
  }
}

The Identity Map

A record loaded once by id is cached in the store. Asking for it again gives you the same JS object, so updates flow everywhere it’s rendered:

const a = await this.store.findRecord('post', 1);
const b = await this.store.findRecord('post', 1);
a === b; // true — same identity

That identity map is what makes Ember Data feel reactive — change one record and every template referencing it re-renders.

Models →