I am new to node-postgres and I want to insert a row in a table using node-postgres, where one column value is an array of strings and one an array of integers.
Earlier I used to use sequelize and now I am not using any ORMS, want to use the native library for postgres in Node.
let names =['abc', 'qwe', 'aaa'];
let type = [2, 3, 4, 5];
let query = 'INSERT INTO sample(names, type) VALUES ($1, $2)' ;
db.query(query, [names, type], (err, res) => {
if (err) {
return (err)
}
return res.send(res.rows[0])
})
I am thrown an error invalid syntax near "["