A
A
Alexander Koshelev2019-08-02 13:54:12
PostgreSQL
Alexander Koshelev, 2019-08-02 13:54:12

How to add multiple rows to database using squelize?

Good day to all!
I connected to the database, defined the table model and I can add rows there, but only one row of data, I can’t find in the manuals how to add several rows, I tried with an array, an object, but it’s not that!

db.sync({force: false}).then(()=>{
    User.create({
    link: 'test1',
    views: '1',
    likes: '1'
  },{
    link: 'test2',
    views: '2',
    likes: '2'
  })
})

With this code, only one line is added, the second is not added, the question is that it will be necessary to add many lines at once in the future, how to do this please tell me!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-08-02
@Xandr24

bulkCreate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question