I have a method which returns some configurations.
But inside that I am running some heavy queries which takes lots of times e.g:
Meteor.users.update();
Article.find().update();
Now these 2 queries takes 5 to 6 seconds, I need these queries to run in background.
Is there any way in Meteorjs to run heavy tasks in background like we do in nodejs with worker threads?
Have a look at this discussion about using web workers with Meteor.
Is there a way to use Web workers in Meteor ? I need to process bulk data in the background while not blocking the UI.
Many Thanks,
Beemer
@allerion The issue I am facing is that in worker.js I get error Meteor is not defined
hassansardarlecodeur:
But inside that I am running some heavy queries which takes lots of times e.g:
Meteor.users.update();
Article.find().update();
Now these 2 queries takes 5 to 6 seconds, I need these queries to run in background.
As mentioned in the other thread, it’s your queries that are the problem. I can’t imagine that you need to run them without any condition, so avoid updating docs that don’t need to be updated in the first place.