问题描述
在我使用的应用程序中,我需要在我的模型中使用关系例如,我有这样的发布和评论模型:
In my application im using LSA and im need to use relation in my model for example i have post and comment models like this :
App.Post = DS.Model.extend({
title:DS.attr('string'),
comments:DS.hasMany('comments')
});
App.Comments=DS.Model.extend({
content:DS.attr('string'),
post:DS.belongsTo('post')
});
我想知道要在帖子和评论之间创建一个小孩关系,以及如何更新帖子的公告
i want to know ho to create a child relationship between post and comments and how to update commnets of post.
推荐答案
我也一直在努力做到这一点。请参阅和
I've also been struggling to do this properly. See What is the correct way to persist child model with Ember.js? andEmber children defined by a hasMany relationship suddenly change to embedded model
我最终写了我自己的修复问题found.请参阅此处的拉动请求:
I ended up writing my own fix for the problems I found. See the pull request here: https://github.com/rpflorence/ember-localstorage-adapter/pull/26
这篇关于LocalStorage数据适配器,并在emberjs中有很多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!