ember.js是否仅使用Em.Object.Extends就支持HasMany?

ember.js是否仅使用Em.Object.Extends就支持HasMany?,ember.js,Ember.js,目前,我的基本hello world ember应用程序具有以下模型对象 ChatApp.User = Em.Object.extend({ username: null, other: null }); ChatApp.Message = Em.Object.extend({ message: null }); 我想改进这一点,因为用户有许多消息-这可以按原样完成吗?如果不是,那么在0.9.8中,今天的首选方法是什么?我将使用余烬数据 它会给出类似于: ChatAp

目前,我的基本hello world ember应用程序具有以下模型对象

ChatApp.User = Em.Object.extend({
    username: null,
    other: null
});

ChatApp.Message = Em.Object.extend({
    message: null
});

我想改进这一点,因为用户有许多消息-这可以按原样完成吗?如果不是,那么在0.9.8中,今天的首选方法是什么?

我将使用余烬数据

它会给出类似于:

ChatApp.User = DS.Model.extend({
  username: DS.attr('string'),
  messages: DS.hasMany('ChatApp.Message')
});

ChatApp.Message = DS.Model.extend({
  message: DS.attr('string')
  user: DS.belongsTo('ChatApp.User')
});

我会使用余烬数据

它会给出类似于:

ChatApp.User = DS.Model.extend({
  username: DS.attr('string'),
  messages: DS.hasMany('ChatApp.Message')
});

ChatApp.Message = DS.Model.extend({
  message: DS.attr('string')
  user: DS.belongsTo('ChatApp.User')
});

你能详细说明一下吗?您想在ChatApp.User中保存ChatApp.message对象数组吗?这对于客户端模型(我认为它是有效的)有意义吗?您是否查看了余烬数据?它管理着这种关系。你能详细说明一下吗?您想在ChatApp.User中保存ChatApp.message对象数组吗?这对于客户端模型(我认为它是有效的)有意义吗?您是否查看了余烬数据?它管理这些关系。这里是超级新手的问题-我需要另一个js文件来使用DS.Model吗?我注意到DS.Model在0.9.8中抛出了一个异常,您需要使用ember-data.js。您可以在ember.js 1.0版本下载它,它已经包含在内了。这里有一篇关于超级新手问题的文章——我需要另一个js文件来使用DS.Model吗?我注意到DS.Model在0.9.8中抛出了一个异常,您需要使用ember-data.js。您可以在ember.js 1.0版本下载它,它已经包含在内了。网站上有一篇关于余烬数据的文章