I have certain doubts with respect to Ember Data. I have a post and comments model.
//post.js
comments: DS.hasMany('comment')
//blog.js
post: DS.belongsTo('post')
I can create a comment for a particular "post" using
let blogPost = this.get('store').findRecord('post', 1);
let comment = this.get('store').createRecord('comment', {
post: blogPost
});
But how can i fetch all the comments for a particular post? Like, I have multiple posts which has many comments and i want all the comments for a particular post id, say posts/id/comments
What is the right way to fetch the comments for a particular post id from the store and server?
The server response i get is only the id's of the comments while "findRecord"ing a post. I am following the REST API format and using REST Adapter and REST serializer for customizations.
Thanks in advance.
See Question&Answers more detail:os