Skip to main content
zerotal

Documentation


Documentation / @zerotal/core / contracts / TransactionContext

Interface: TransactionContext()

Defined in: contracts/transaction.ts:19

The database-transaction contract — the opaque handle the kernel carries for a request or scope without depending on @zerotal/orm.

HttpContext._transaction and RequestContext.transaction() are typed as this so the ORM can stash the active connection on the request and read it back, while core never learns what a Bun.sql connection actually is. The ORM's SQLInstance is a structural supertype of this — it adds begin() / end() — so assigning one here is checked, not cast.

Remarks

Core only ever holds the value; it never calls it. The single call signature is enough to make the carried value type-safe while leaving the full query API to the ORM, which narrows back to SQLInstance at its own boundary.

TransactionContext<T>(strings, ...values): Promise<T[]>

Defined in: contracts/transaction.ts:25

Run a query via a tagged template. Present so the contract is a genuine SQL-connection shape rather than an empty marker; the ORM's connection type is assignable to it.

Type Parameters

T

T = Record<string, unknown>

Parameters

strings

TemplateStringsArray

values

...unknown[]

Returns

Promise<T[]>