Is it possible to have rowMode: 'array'
and named parameters at the same time? Right now, with the code below, I'm getting syntax error at or near "$"
db.query({
text: `
select task_nr, commitment
from surveys
where email = $<email> and id = $<id>
order by task_nr
`,
values: {email: email, id: id},
rowMode: 'array',
})
No, it is not possible, because rowMode
is strictly part of the Parameterized Query, which by definition forwards query formatting to the driver->server where such thing as Named Parameters does not exist.
Unfortunately, if you really need to use rowMode
, you can only use the basic $1, $2...
variable formatting as supported by the server.
Strictly speaking, rowMode
is not that valuable, it is fairly easy to reformat the data, and then just use pg-promise default formatting with all its nice formatting features.