在Ember.js中从belongsTo关联中查找记录

在Ember.js中从belongsTo关联中查找记录,ember.js,ember-data,Ember.js,Ember Data,如何从余烬模型中获取关联记录?或者:如何从承诺对象获取记录 客户模型 Docket.Customer = DS.Model.extend({ name: DS.attr('string'), initial: DS.attr('string'), description: DS.attr('string'), number: DS.attr('string'), archived: DS.attr('boolean'), projec

如何从余烬模型中获取关联记录?或者:如何从承诺对象获取记录

客户模型

Docket.Customer = DS.Model.extend({
  name:        DS.attr('string'),
  initial:     DS.attr('string'),
  description: DS.attr('string'),
  number:      DS.attr('string'),
  archived:    DS.attr('boolean'),
  projects:    DS.hasMany('project',{ async: true })
});
Docket.Project = DS.Model.extend({
  name:        DS.attr('string'),
  description: DS.attr('string'),
  number:      DS.attr('string'),
  archived:    DS.attr('boolean'),
  customer:    DS.belongsTo('customer', { async: true })
});
项目模型

Docket.Customer = DS.Model.extend({
  name:        DS.attr('string'),
  initial:     DS.attr('string'),
  description: DS.attr('string'),
  number:      DS.attr('string'),
  archived:    DS.attr('boolean'),
  projects:    DS.hasMany('project',{ async: true })
});
Docket.Project = DS.Model.extend({
  name:        DS.attr('string'),
  description: DS.attr('string'),
  number:      DS.attr('string'),
  archived:    DS.attr('boolean'),
  customer:    DS.belongsTo('customer', { async: true })
});
查找方法

var project = this.store.find('project', id).then(function(data) {
  console.log(data.get('customer').toString());
});
控制台输出

<DS.PromiseObject:ember654> 

然后在get上使用另一个:)


哦,该死!脸掌。谢谢