10.14.0
- Type
Result
(returned from methods result and multiResult) is now iterable, automatically exposing rows of data:
const res = await db.result('select * from users');
for (const r of res) {
console.log(r); // print each row
}
Above, res
(of type Result
) is now iterable, automatically exposing res.rows.values()
.
To that end, the typescript declarations have been updated accordingly.
TypeScript example
class User {
id: number;
login: string;
active: boolean;
}
// example of typed query result
const res = await db.result<IResultExt<User>>('select * from users');
for (const r of res) {
// r here is strongly-typed
console.log(r);
}