I want to use the same pattern for destructuring query results, but seems I cannot. In the following code:
var {rows} = await client.query("SELECT id FROM mytable;");
var Id = rows[0].id; //destructured here as expected
if I then follow that with:
rows = await client.query('SELECT max(id) as id FROM table2;');
The only way I can access the value is like this:
rows.rows[0].id;
Shouldn't I be able to access as in the first instance, like this?
rows[0].id;
Do I need to somehow reset {rows}
?
Very new to JS so finding my way.