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

548
Views
How to post/inesrt many documents at once in mongodb using express?

I used this command but it's not working!. I want to insert many documents at once in mongodb using express js ...

app.post("/products", async (req, res) => {
      const body = req.body
      const docs = [{ body:body }] 
      console.log(docs);
      const options = { ordered: true }
      const result = await productCollection.insertMany(docs, options)
      res.send(result)
})

It's giving the error below:

callback(new error_1.MongoServerError(document));
BSON field 'insert.documents.0' is the wrong type 'array', expected type 'object'
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Look at productCollection schema model - looks like you set it to Object while trying to insert an Array.

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!