Reputation: 117
I'm making a dating app. Every day at midnight I want 'new matches' to be randomly found and displayed to a user.
If anyone could give a give high level overview of how this would work I'd be really grateful?
Upvotes: 2
Views: 967
Reputation: 8552
If want to execute a Node task every midnight then Cron jobs is a powerful, yet simple tool that can help us get there. You can user Cron Package to achieve this in node.
You can add cron dependency using
npm install cron
You can modify following script
var CronJob = require('cron').CronJob;
var job = new CronJob('00 00 01 * * *', function() {
console.log('You see this message every day 01 AM America/Los_Angeles');
}, null, true, 'America/Los_Angeles');
Where you can replace console.log with the logic you want to implement the code that will find match for each users of app and replace timezone with yours.
Upvotes: 2