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

122
Views
Limit number of mongodb documents inserted at the same time

I am using find to query and then insert almost 1000 documents in a mongodb collection.Is there a way to limit the number of documents being inserted at the same time.(My basic objective here is to find all documents with a particular year from a collection and then copy/insert them within the same collection with updated year and few other sections.The problem is when this API is in progress other API's gets a delay.So I need to change the concurrency rate at which these happens).

async function Options(fromYear,toYear){
await db.collection('Options').find({"year":parseInt(fromYear)}).forEach(function(doc){
    var newDoc = doc;
    delete newDoc._id;
    newDoc.year = parseInt(toYear);
    db.collection('Options').insert(newDoc);
    });
}
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!