DS.Model.relationshipsByName

relationshipsByNameEmber.Mapstatic

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

A map whose keys are the relationships of a model and whose values are relationship descriptors.

For example, given a model with this 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 property would contain the following:

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

var relationshipsByName = Ember.get(Blog, 'relationshipsByName');
relationshipsByName.get('users');
//=> { key: 'users', kind: 'hasMany', type: 'user', options: Object, isRelationship: true }
relationshipsByName.get('owner');
//=> { key: 'owner', kind: 'belongsTo', type: 'user', options: Object, isRelationship: true }
doc_EmberJs
2016-11-30 16:50:18
Comments
Leave a Comment

Please login to continue.