at the moment if I would delete an comment at post, I have to load all hasMany relationships before. If all hasMany relationships loaded, than I can remove an comment form Post Object. Is there an other solution? It is really tricky to load all hasMany relations every times. if I add an object to an hasMany relationship.
If I understand you correctly then no, you need to retrieve the model before you can delete it if you’re sticking to “pure” ember-data. You can go around ember-data to trigger the delete on the back-end directly, though if you go that route you should probably first check whether the model is loaded. Maybe define a new method to do just that on your Store for it?
ED will soon have lazy many arrays. You will be able to do
//This will not actually fetch all the records like it does now
post.get('comments').then(function(comments) {
//this will fetch one comment
comments.objectAt(50).then(function(comment) {
//this will remove it
comments.removeObject(comment);
});
}):
@terzicigor in this case what does the comments arrays is? And how does it would work in the case where I want to fetch all the comments on the relations?
I have the same use case, I would delete an existing comment from, but have load all hasMany relations of my object before. So I have to load processors and comments before, booth promises should be resolved and than I can delete an comment object and do an save. If I don’t load the users before, the array is empty on save method.