Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 1.21 KB

require-async-inverse-relationship.md

File metadata and controls

41 lines (27 loc) · 1.21 KB

ember/require-async-inverse-relationship

This rule ensures that the async and inverse properties are specified in @belongsTo and @hasMany decorators in Ember Data models.

Rule Details

This rule disallows:

  • Using @belongsTo without specifying the async and inverse properties.
  • Using @hasMany without specifying the async and inverse properties.

Examples

Examples of incorrect code for this rule:

import Model, { belongsTo, hasMany } from '@ember-data/model';

export default class FolderModel extends Model {
  @hasMany('folder', { inverse: 'parent' }) children;
  @belongsTo('folder', { inverse: 'children' }) parent;
}

Examples of correct code for this rule:

import Model, { belongsTo, hasMany } from '@ember-data/model';

export default class FolderModel extends Model {
  @hasMany('folder', { async: true, inverse: 'parent' }) children;
  @belongsTo('folder', { async: true, inverse: 'children' }) parent;
}

References