Skip to content

10.14.0

Compare
Choose a tag to compare
@vitaly-t vitaly-t released this 15 Nov 05:24
· 136 commits to master since this release
  • 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);
}