A) Whilst executing the res.forEach loop the result set (cursor) is updated to reflect the changes that happened on the collection?
or
B) The forEach loop will continue to be executed with the original result (cursor) until the last document is read, then and only then the reactivity is executed
or
C) something else
???
Can someone enlighten me? This is obviously very important for apps operating with multiple users working on the same collection. If A is true that would mean a res.forEach could be kept going continuously as long as new data is inserted into the collection.
If you are using it within a reactive computation like Tracker.autorun() or a template helper, yes, it will update the result (synchronously and sequentially).
But if you are using it outside a reactive computation, like a normal function, a method, somewhere on the server etc, it will not rerun.
I am still thinking that Cursor is always reactive (ofc in reactive context like tracker, helper etc)
But .forEach and .map have special magic which will not recalculate new value for every document, but only for changed ones.
Instead of doing fetch and than doing .forEach or .map or whatever above resulted array which will recalculate everything again.
Sorry Robert, your comment is unclear to me. I’m currently using only .find() and not .find().fetch() (correction, double checked my code and I indeed use .find().fetch() in one instance).