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

86
Views
How do I make a function tick atomically if the document is not modified after a certain period of time

Hello I am working with mongoose/mongodb and have this data structure

{
   step: "Lorem",
   status: "in-progress",
   bool: true,
   startedAt: Date.now(),
   inactive: false
}

how do I make it so if there are no changes to the first three attibutes after a certain period of time inactive is set to true

Thanks for any assistance!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You need an extra field updateAt, everytime step or status or bool changed, you also need to change updateAt.

Finally you can check updateAt.

{
   step: "Lorem",
   status: "in-progress",
   bool: true,
   startedAt: Date.now(),
   updateAt: Date.now(),
   inactive: false
}
about 4 years ago · Juan Pablo Isaza Report

0

Use a CRON, here is some pseudo code

//query
{$lte: updatedAt: today, subtracted by 2months}
//update
{$set: attr to 'whatever you want'}
//db call
db.collection.updateMany(query, update)
about 4 years ago · Juan Pablo Isaza Report
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!