First of all I carefully read the documentation here and checked similar StackOverflow questions. I have a sequence of SQL requests. When I write this, everything works fine:
const { rows } = await db.query(`
SELECT * FROM table
WHERE id = ${id}`)
But I'd like to make several requests, that's why I thought about writing this:
let rows;
{ rows } = await db.query(`
SELECT * FROM table
WHERE id = ${id}`)
// do something with the rows
{ rows } = await db.query(`
SELECT * FROM othertable
WHERE id = ${id}`)
// do something else
But I have this error:
{ rows } = await db.query(`
^
SyntaxError: Unexpected token '='
Seeing the documentation, it appears to be a simple assignment, I don't know what is wrong with this. Any help would be very kind :)
rows = (await db.query(/* ... */)).rows