relationshipsEmber.Map
static
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
1 2 3 4 5 6 7 | 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:
1 2 3 4 5 6 7 8 9 | 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' } ] |
Please login to continue.