Closed paranoico closed 7 years ago
you have to define a before.remove and check a modifier
The modifier will tell you if you are going to delete the complete collection ({}
for instance) but there are multiple queries that would delete the complete collection, but they are all dependent on your document schema. For instance, if all the documents of your collection have a flag like isWhatever
to true
, then a modifier like { isWhatever: true }
will also delete all the documents
Thanks @namirsab.
We were trying to detect when Meteor was making a collection empty, we have found on Mantrajs that it can happen almost at any moment and it seems to be when Meteor determines collection is not used anymore.
But now we have chosen other method. Regards.
You mean in the client? Meteor will empty a colllection if all subscriptions are removed. Basically because if you are not subscribed to any data, collections in the client side should be empty.
That is exactly the strange thing: Yes, it is in the Client, we thing it is something about Meteor or may be React, but we subscribe to about 30 collections, all in same container. A seconds after, many of them are erased, and only maintained those referenced in find() method in code.
That is why I posted the question in first place, afterwards, I changed the behavior to use ccorcos:subs-cache to prevent subscriptions from been stopped (we found that it appeared to be like meteor stopping they).
As far as we have tested, it now works correctly.
Thanks.
mmm you are using React I'm not sure with React, but with blaze all template subscriptions are removed once the template is destroyed. In React i think there are several ways to work with meteor data. Then if this is not related with collection-hooks i will close the issue. Thanks!
This is not precisely an Issue, but a question:
¿Does meteor-collection-hooks has some way to detect when entire collection is cleared and therefor all documents are going to be erased?
We cannot find anything in before.remove hook to detect such a thing.
Thanks in advance.