Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
Best way to update many documents in a collection in mongo?

Basically, I want to check a schedule field in every document, and if Date.now() falls within the bounds of the schedule, I want to set isActive to true.

{

schedule: {
    start: (Date object),
    end: (Date object)
},
isActive: false

}

That in itself is simple, but my issue is that this collection can potentially have hundreds of thousands of documents. I also need this to run every 30 minutes using cron.

Is there any way to efficiently do this without totally locking up my application and/or database every 30 minutes for however long it takes?

Do I need to call save() on each document individually or is there a way I can save all of them at once?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!