EN

@core / db

1.0.0 ▾
verifiedMIT
GitHub

Postgres with Drizzle: shared client, per-module schemas, transactions and ULID ids

Code8 filesContext~547 tokensscan passed

The exact tree that will be injected, after .genpmignore. Pinned to

src/lib/db/transaction.tsread-only · 28d4b9f
import { type Db, getDb, type Tx } from './client.js';

/**
 * Ejecuta `fn` en una transacción: si lanza, se hace rollback de todo. Los helpers de otros módulos aceptan un
 * `Executor`, así que pásales `tx` para que participen en la misma transacción.
 */
export function withTransaction<T>(fn: (tx: Tx) => Promise<T>, db: Db = getDb()): Promise<T> {
  return db.transaction((tx) => fn(tx as Tx));
}

Report @core/db

Sign in with GitHub to report a package.