@warsam-e/rift
v1.1.1
Published
A lightweight postgres library for TypeScript
Readme
@warsam-e/rift
A lightweight postgres library for TypeScript
Installation
% bun i @warsam-e/riftBasic Usage
import { init_pool, pool, query } from '@warsam-e/rift';
const initial_script = `
create table if not exists list (
id int not null primary key,
value text not null
);
`;
await init_pool({
auth: {
host: 'localhost',
port: 5432,
user: 'test',
password: 'test',
database: 'test',
},
initial_script,
max: 1000, // maximum number of clients in the pool
});
async function get_some(ids: number[]) {
// `using` automatically releases the connection once the block is exited
using conn = await pool.connect();
return query(conn, 'select * from list where id = any($1)', [ids]);
}
let list = await get_some([1, 2, 3]);
console.log(list);