durcno@1.0.0-alpha.30
Minor Changes
-
c71f751 - Thanks to @almahdi404 !
feat(connectors): support prepared statements to postgres connector
Add support for executing queries as prepared statements in the
postgres(postgres.js) connector.Prepared Statements in Postgres Connector
The
postgresconnector now passes{ prepare: true }topostgres.jsduring query execution when theprepareflag is enabled:import { database, defineConfig, eq, prepare } from "durcno";import { postgres } from "durcno/connectors/postgres";export const db = database(schema,defineConfig({schema: "./schema.ts",connector: postgres({dbCredentials: { url: process.env.DATABASE_URL! },}),}),);const findUser = prepare({ id: Users.id.arg() }, (args) =>db.prepare().from(Users).select("*").where(() => eq(Users.id, args.id)));const users = await findUser.run(db, { id: 1 });
Patch Changes
-
54c3a09 - Thanks to @almahdi404 !
fix(db): make db.raw() rowsHandler argument optional
db.raw()required arowsHandlercallback positionally, even though passingundefinedwas already handled at runtime and the documentation listed the argument as optional. This made the common case — executing a raw query and getting the rows back — impossible to express without a redundant identity handler.// Before: had to pass a pass-through handlerconst rows = await db.raw<{ id: bigint; }[]>("SELECT id FROM users",[],(rows) => rows,);// After: rowsHandler is optionalconst rows = await db.raw<{ id: bigint; }[]>("SELECT id FROM users");This is a non-breaking change; existing three-argument calls behave exactly as before.