Closed thearabbit closed 9 years ago
This package doesn't handle cascade delete of related documents. You can do it yourself with collection-hooks. I think there are some relationship packages too you can use.
I think that if the primary field is removed, so the reference field should be removed too. Because the reference field will can't get data. I would like to request you for add like this:
Comments.cacheDoc('post', Posts, ['title'], {
referenceField: 'postId',
cacheField: 'cachedPost',
removal: true // false for default
});
What do you think?
After remove, if I insert the same primary fields again it update the cachDoc or not?
Yes, if you insert a document with a primary field that matches another document's reference field, the cache field will update. So you can insert a comment before a post, like this:
Comments.insert({
_id: 'comment1',
post_id: 'post1'
});
// Comments.findOne('comment1')._post == undefined
Posts.insert({
_id: 'post1',
…
});
// Comments.findOne('comment1')._post == {…}
How to remove all of reference records, if the primary is removed?