Suppose I want to insert multiple rows into a table in PostregSQL. The example below shows how to do that using only one row, but what if I want to insert several rows? How to do that? If I have several names with the same email?
const text = 'INSERT INTO users(name, email) VALUES($1, $2) RETURNING *'
const values = ['brianc', 'brian.m.carlson@gmail.com']
// promise
client
.query(text, values)
.then(res => {
console.log(res.rows[0])
// { name: 'brianc', email: 'brian.m.carlson@gmail.com' }
})
.catch(e => console.error(e.stack))