I have two models that look a bit like this:
App.Book = DS.Model.extend({
tags: DS.hasMany('tag')
});
App.Tag = DS.Model.extend({
books: DS.hasMany('book', { async: true })
});
The problem is that when I add/remove a tag to/from a book and then save, the books
property on the corresponding tag
model is not updated. EDIT: After whipping up a JS Bin (http://jsbin.com/ucanam/1574/edit), I’ve determined that this is happening because async
is set to true
. I’m not sure what to do here. A tag may have millions of books associated with it. If I’m not mistaken, then, setting async
to false
isn’t really an option, right? Then is there a way to refresh the association even with async
set to true
?
Btw, the way I’ve been adding/removing tags is as follows:
this.store.find('tag'), 123).then(function(tagToRemove) {
book.get('tags').removeRecord(tagToRemove);
book.save();
});
this.store.find('tag', 456).then(function(tagToAdd) {
book.get('tags').pushObject(tagToAdd);
book.save();
});
Also of note: After adding/removing a tag to/from a book, calling book.get('isDirty')
still returns false
. Why?