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

379
Views
how can insert array consisting of multiple objects using sequelize and node?

In below block line of code i want to insert an array of multiple object. but it's not working.

let Bookarray = [{author:"john matt", BookName:"Beauty of Nature"},
{author:"Mick Foley", BookName:"Have A Nice Day"},
{author:"Kevin Sullivan.", BookName:"WWE 50"},
{author:"Brian Shields And Dean Miller", BookName:"35 Years Of Wrestlemania"},
{author:"Mick Foley", BookName:"Foley Is Good"},
]
 
let InsertObj = await BooksDetails.create(Bookarray);

What should i do?

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

0

For an array containing multiples objects use bulkCreate.

let InsertObj = await BooksDetails.bulkCreate(Bookarray);
about 4 years ago · Juan Pablo Isaza Report

0

i don't know for certain but I imagine

Promise.all( Bookarray.map(BooksDetails.create) )

Will do individual inserts. I bet there is a way to insert multiple records that would be more efficient.

Do what @ijaz recommends

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!