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

303
Views
get update value after an updateOne()

is it possible to get all updated value/value where there is a diff after a call of updateOne()

 _.each(gameResult, function(gameResult){
    bulk.find({"user" : gameResult.user, "section" : gameResult.section , "code" : gameResult.code}).upsert().updateOne(gameResult);
  })

imagine my value in the db before the update are :

1, 1, 1, 1

gameResult is :

1, 2, 1 , 3

So my db is updated : 1, 2, 1, 3

Is it possible to get all value who are changed, so here how can i get my two object 2 and 3 cause i need it in the code.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You are looking for findAndModify.

This performs an update while also returning the existing document from the database. By default, this method returns the document before the changes are applied (this behavior can be changed with the new:true option). So you can easily compare the returned document with your local document to find the differences.

Unfortunately findAndModify isn't supported by bulk operations, so you need to do it document-by-document.

over 4 years ago · Santiago Trujillo 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!