How to run a function with a collection query



How can I do this. I need to run a function that checks if some value in my collection is false and if it finds something then it checks logic and changes the value to true if the logic is met. I tried to to with Interval but this will cause issue if my collection everything is already changed to true, then there’s no false and the query gives error

is there any smarter way to do it? this is my check right now which gives error when nothing is false in the collection. this part - productDate = Products.findOne({isItReady: false});


Do you really need to update the collection?

I’ve probably misunderstood, but isn’t it sufficient to form the query (for example in a Meteor.publish) to only make available those documents which fulfil the selection criteria? Something along the lines of:

Meteor.publish('isActive', function() {
  return Products.find({readyTime:{$gte:{}}});


ofc it gives you error, as that productDate is empty and u r accessing its properties as if it was object.
suggestion above is OK too, but if you just want to prevent error you need if condition to check if productDate is not empty and wrap code which depends on it.