You can try this package https://atmospherejs.com/vsivsi/job-collection.
My think about that is a “task”, that run every day, one “server method”, so:
The Method: (to run and change the boolean value, run only on server side, not called from client)
Meteor.methods({
resetBoolean: function(userId) {
this.unblock();
// Check connection before run
if (this.connection === null) {
if (!userId) {
throw new Meteor.Error('No user ID found!');
}
var result = Meteor.users.update(userId, {$set: {boolean: false}}, function(error) {
if (error) {
throw new Meteor.Error(error);
}
});
return result;
} else {
throw new Meteor.Error('server-only-method', 'Sorry, this method can only be called from the server.');
}
}
});
Define the “jobs collection”, create the task and run in “auto mode”:
// Create jobs collection
var myJobs = JobCollection('myJobQueue');
// Create the "Job" (task)
var runJobs = myJobs.processJobs(['resetBoolean'], function(job, callback) {
var userId = job.data.userId;
Meteor.call('resetBoolean', userId, function(error) {
if (error) {
job.fail(error);
} else {
job.done();
}
callback();
});
});
// Run the Job in "auto mode"
myJobs.find({type: 'resetBoolean', status: 'ready'}).observe({
added: function() {
runJobs.trigger();
}
});
Now you can insert new Job (task) to run:
// Insert new Job to run, with user ID
var resetBoolean = new Job(myJobs, 'resetBoolean', {userId: 'xxxxxxx'});
resetBoolean
.priority('normal') // Priority
.retry({
retries: 5, // Try 5 times before set failed
wait: 15 * 60 * 1000 // 15 minutes between attempts
})
.repeat({
schedule: jc.later.parse.text('at 00:00 am'); // https://bunkat.github.io/later/parsers.html#text
});
.save(); // Save on "jobs collection"
Done, now after you add new “jobs” with the user ID will do this job automatically, you can check this collection on database and see. But I recommend that you learn all documentation, also look for security issues, I show just an example, this work for me.