The documentation here clearly outlines that it is a bad practice to write
Promise.all(data.map(d => db.none('insert into...', d)))
which is querying against root database protocol. Hence it is better to write
db.task(t => t.batch(data.map(d => t.none('insert into...', d))));
However, is it wrong to write this if I do not intend to use BatchError
or query duration
(ref)?
db.task(async t => {
await Promise.all(data.map(d => t.none('insert into...', d)));
});
By the looks of it, it still uses shared connection protocol instead of root connection.