Closed petr24 closed 7 years ago
Yes infinite loops do happen and you have to use the direct
method at some point which will not trigger the hooks.
@jamesgibson14
Gotcha, yeah I had a if statement that prevented the infinite loop, but I had to remove it, and now get a infinite loop case.
So I'll close this for now with a note that this might need some documentation.
I'll re-open if you feel this isn't resolved.
Yeah that works, I'll drop this link here that talks about handling the loop issue. In case someone comes across this looking for an answer. https://github.com/matb33/meteor-collection-hooks/issues/3
Hey Matt,
Wanted to know how are you avoiding an infinite loop scenario with data that's denormalized.
Example
DocA updates name, and DocA is denormalized. So when DocA is updated, I also want to update DocB and DocC with DocA's update.
So in my "after" hook, I check if DocA has any docs it needs to update. And if it does, my query is really simple. "Collection.update(query, modifier, {multi: true})" but when the update goes through, the "before" hooks are fired, but the "after" hook is not fired for DocB and DocC.
How are you preventing this? I was assuming an infinite loop scenario would be happening.
Thanks