import { init_pool, pool, query } from'@sncutils/db';
constinitial_script = ` create table if not exists list ( id int not null primary key, value text not null ); `;
awaitinit_pool({ auth: { host:'localhost', port:5432, user:'test', password:'test', database:'test', }, initial_script, max:1000, // maximum number of clients in the pool });
asyncfunctionget_some(ids: number[]) { // `using` automatically releases the connection once the block is exited usingconn = awaitpool.connect(); returnquery(conn, 'select * from list where id = any($1)', [ids]); }