我试图用嵌入式火力适配器将嵌入式记录添加到火力基地,没有任何运气。所以我有一个帖子和评论模型,我希望它在firebase中看起来像这样:
{
"posts": {
"post_id_1": {
"comments": {
"comment_id_1": {
"body": "This is a comment"
}
}
}
}
}
我目前得到了这个:
{
"posts": {
"post_id_1": {
"comments": {
"comment_id_1": true
}
}
},
"comments": {
"comment_id_1": {
"body": "This is a comment",
"post": "post_id_1"
}
}
}
我已经厌倦了文档Docs,但只能让异步工作,但嵌入式关系不起作用。我正在使用现有的火灾基础数据库,因此我无法更改后端的数据结构,它需要采用嵌入式格式。
最后这是最好的方法吗?还是有更好的方法?
我也按照Docs
的建议尝试了这样做let post = this.get('post');
let newComment = this.store.createRecord({
body: 'My super fun embedded comment'
});
post.get('comments').then(function(comments) {
comments.addObject(newComment);
// The comment is automatically saved when we call save() on the parent:
return post.save();
});
控制台出错:
Error: Assertion Failed: Passing classes to store methods has been removed. Please pass a dasherized string instead of [object Object]