I'm trying to add embedded records into fire base with the ember fire adapter without any luck. So I've got a post and a comment model and I would like it to look like this in firebase:
{
"posts": {
"post_id_1": {
"comments": {
"comment_id_1": {
"body": "This is a comment"
}
}
}
}
}
I've currently got this:
{
"posts": {
"post_id_1": {
"comments": {
"comment_id_1": true
}
}
},
"comments": {
"comment_id_1": {
"body": "This is a comment",
"post": "post_id_1"
}
}
}
I've tired following the documentation Docs but can only get the Async working but the not the embedded relationship to work. I'm working with an existing fire base database so I can't change the data structure on the backend it needs to be in the embedded format.
Finally is this best of way of doing this or is there a better way of doing?
I've also tried doing this as suggested here 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 in console:
Error: Assertion Failed: Passing classes to store methods has been removed. Please pass a dasherized string instead of [object Object]
Aucun commentaire:
Enregistrer un commentaire