@btravstack/prisma / index
index
Type Aliases
PrismaLike
type PrismaLike = object;Defined in: prisma/src/prisma.ts:23
All this starter needs of a client: a pool it can close. A generated Prisma client satisfies it structurally, and so does an extended one — $extends preserves $disconnect — which is why the application's own client type flows through untouched.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
$disconnect | readonly | () => Promise<void> | - | prisma/src/prisma.ts:24 |
$queryRaw | readonly | (query, ...values) => Promise<unknown> | What the health check asks. Part of the contract rather than optional because every generated Prisma client has it, and a probe that has to feature-detect its own client cannot report the difference between "the database is down" and "this client cannot be asked". | prisma/src/prisma.ts:31 |
PrismaOptions
type PrismaOptions<C> = object;Defined in: prisma/src/prisma.ts:35
What prismaDatabase is handed.
Type Parameters
| Type Parameter |
|---|
C extends PrismaLike |
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
client | readonly | (adapter) => C | Builds the client from the driver adapter, which is already constructed from the environment's URL. This is the one thing the starter cannot own: a Prisma client is generated per application from its own schema, so there is no client type to ship. Applying @unthrown/prisma's extension belongs here too, so the returned type is exactly the one the application will hold. | prisma/src/prisma.ts:45 |
Functions
prismaDatabase()
function prismaDatabase<N>(name): <C>(__namedParameters) => Module<ResolvedExports<readonly [PortClassOf<N, C>, typeof HealthChecks, typeof Instrumentations]>, ConfigInvalid,
| Exclude<Env, Available<[], readonly [Provider<PortInstance<`${(...)}Config`, {
url: ...;
}>, ConfigInvalid, Env> & object, Provider<Observers, never, never> & object, Provider<PortInstance<string, C>, never, Scope | PortInstance<..., ...> | Observers> & object, Provider<HealthChecks, never, PortInstance<string, C>> & object, Provider<Instrumentations, never, Logger> & object]>>
| Exclude<Logger, Available<[], readonly [Provider<PortInstance<`${(...)}Config`, {
url: ...;
}>, ConfigInvalid, Env> & object, Provider<Observers, never, never> & object, Provider<PortInstance<string, C>, never, Scope | PortInstance<..., ...> | Observers> & object, Provider<HealthChecks, never, PortInstance<string, C>> & object, Provider<Instrumentations, never, Logger> & object]>>> & object;Defined in: prisma/src/prisma.ts:67
A Prisma client whose pool is the application scope's.
Returns the three pieces a composition root needs and nothing more: the config provider binding the connection string, the port the client is reached through, and the resourceful provider that opens it and closes it again. Put both providers in a module's provides and export the port.
The pool closes on every exit path, including a boot that fails after this provider ran — that is what makes it resourceful rather than a plain value. $disconnect ends the driver adapter's pool without killing the client; Prisma dials again lazily on the next statement, which is why no spec asserts that a released client refuses to query.
Migrations are not run here. A deployment runs prisma migrate deploy against this same URL before the process starts; an application that migrates itself at boot races every other replica.
Type Parameters
| Type Parameter |
|---|
N extends string |
Parameters
| Parameter | Type |
|---|---|
name | N |
Returns
<C>(__namedParameters) => Module<ResolvedExports<readonly [PortClassOf<N, C>, typeof HealthChecks, typeof Instrumentations]>, ConfigInvalid, | Exclude<Env, Available<[], readonly [Provider<PortInstance<`${(...)}Config`, { url: ...; }>, ConfigInvalid, Env> & object, Provider<Observers, never, never> & object, Provider<PortInstance<string, C>, never, Scope | PortInstance<..., ...> | Observers> & object, Provider<HealthChecks, never, PortInstance<string, C>> & object, Provider<Instrumentations, never, Logger> & object]>> | Exclude<Logger, Available<[], readonly [Provider<PortInstance<`${(...)}Config`, { url: ...; }>, ConfigInvalid, Env> & object, Provider<Observers, never, never> & object, Provider<PortInstance<string, C>, never, Scope | PortInstance<..., ...> | Observers> & object, Provider<HealthChecks, never, PortInstance<string, C>> & object, Provider<Instrumentations, never, Logger> & object]>>> & object