我无法embedded hasMany使用ember数据正常工作.
我有类似的东西
App.Post = DS.Model.extend({
comments: DS.hasMany('App.Comment')
});
App.Comment = DS.Model.extend({
post: DS.hasMany('App.Post'),
name: attr('string')
});
Run Code Online (Sandbox Code Playgroud)
我的API返回以下内容GET /post:
[
{
id: 1
comments: [{name: 'test'}, {name: 'test2'}]
},
...
]
Run Code Online (Sandbox Code Playgroud)
我需要发送以下内容POST /post:
[
{
comments: [{name: 'test'}, {name: 'test2'}]
},
...
]
Run Code Online (Sandbox Code Playgroud)
我想与Ember模型合作并让他们提出适当的要求:
var post = App.store.createRecord(App.Post, hash_post_without_comments);
post.get('comments').createRecord(hash_comment);
App.store.commit(); // This should call the POST api
Run Code Online (Sandbox Code Playgroud)
和
var posts = App.store.find(App.Post); // This should call the GET api
Run Code Online (Sandbox Code Playgroud)
当我尝试类似的东西时post: DS.hasMany('App.Post', {embedded: …
有没有办法知道为什么记录在ember数据中处于脏状态,我的意思是什么是已经改变的属性和关系.
调用findAll之后我有isDirty = true,我想调试为什么会这样.
非常感谢