DS.Model.relationships

relationshipsEmber.Mapstatic

Defined in addon/-private/system/relationships/ext.js:325

The model's relationships as a map, keyed on the type of the relationship. The value of each entry is an array containing a descriptor for each relationship with that type, describing the name of the relationship as well as the type.

For example, given the following model definition:

app/models/blog.js
import DS from 'ember-data';

export default DS.Model.extend({
  users: DS.hasMany('user'),
  owner: DS.belongsTo('user'),
  posts: DS.hasMany('post')
});

This computed property would return a map describing these relationships, like this:

import Ember from 'ember';
import Blog from 'app/models/blog';

var relationships = Ember.get(Blog, 'relationships');
relationships.get(App.User);
//=> [ { name: 'users', kind: 'hasMany' },
//     { name: 'owner', kind: 'belongsTo' } ]
relationships.get(App.Post);
//=> [ { name: 'posts', kind: 'hasMany' } ]
doc_EmberJs
2016-11-30 16:50:18
Comments
Leave a Comment

Please login to continue.