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

197
Views
How can I validate or preview an update before execution in mongoose?

I have a mongo document which I would like to update:

votes: [{
  name: 'Bugs Bunny',
  percentage: 50
}, {
  name: 'Mickey Mouse',
  percentage: 49
}]

I want to make sure that the sum of percentage will never exceed 100, when updating an object in the array or adding a new object to the array.

I am wondering is there a way to preview updates and then save them? Or is there a way to rollback to the previous document when percentage > 100?

I've read I can't use validators: How validate $push in update request mongoose?

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!