Store - GradedJestRisk/ember-training GitHub Wiki

Overview

Overview

Ember data relationship:

  • 1:1: belongsTo
  • 1:N: hasMany
  • N:N: hasMany

Paging

Data retrieval modes (like ORM):

  • lazy-loading (default): load as late as possible. As action is asynchronous, take care to use await to access such resources.
  • eager loading: load a early as possible. Will do a full graph traversal, so take care not include links that can make entire database to be retrieved
Any store renewal from Back-Office (except store.query) cause any existing store record to be removed if it's not present again in the response (following relationship/includes link).

TLDR:

  • paginated resources must never be in store
  • all other data should always been loaded

plug to API

Use an adapter on matching level (eg. on application, in file app/adapters/application.js)

import JSONAPIAdapter from '@ember-data/adapter/json-api';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';

export default class Application extends JSONAPIAdapter.extend(DataAdapterMixin) {
  host = 'http://myapi.foo.bar:3000';
}
⚠️ **GitHub.com Fallback** ⚠️