Skip to content
Discussion options

You must be logged in to vote

MongoDB won’t update documents automatically at a specific time by itself.
You need to handle it from your Node.js app.
Simplest way is to use a scheduler like node-cron to run every minute (or your choice) and update bookings whose startTime has passed from "accepted" to "inProgress".
If you need more precise timing or have a lot of bookings, use a job queue like Agenda or Bull to schedule the update exactly at the booking’s start time.
For very simple cases, you could also just check the time when reading the booking and return "inProgress" if the start time has already passed, but this won’t actually change the stored value in the database.

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@sirajahmedx
Comment options

Answer selected by sirajahmedx
Comment options

You must be logged in to vote
1 reply
@sirajahmedx
Comment options

Comment options

You must be logged in to vote
1 reply
@sirajahmedx
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Ask and answer questions about GitHub features and usage Programming Help Discussions around programming languages, open source and software development
4 participants