Connect
Open a handle to an existing database.
connect({ provider }) is the entry point. It constructs a handle; it does not create a database and does not open the client until the provider does so on test, introspect, or query.
import { connect } from "@db-sdk/core";
import { postgres } from "@db-sdk/postgres";
const db = await connect({
provider: postgres({ connectionString: process.env.DATABASE_URL }),
});ConnectOptions
Prop
Type
Database
Handle returned by connect(). Same lifecycle on every provider. Use driver to pick the query tool (for example SQL when driver === "postgres").
Prop
Type
await db.test();
const catalog = await db.introspect();
const result = await db.query(input);
await db.close();