basalt / prisma/src / tenancyExtension
Function: tenancyExtension()
Call Signature
> tenancyExtension(options?): TenancyExtension
Defined in: prisma/src/extension.ts:501
Prisma client extension for the shared-database tenancy mode:
const db = new PrismaClient().$extends(tenancyExtension())
Every query on every model is scoped to ctx().tenant at call time — app code just writes db.project.findMany(). Operations it cannot scope (raw queries, unknown operations) are refused inside a tenant context.
Limits: a foreign-key SCALAR (data: { projectId }) is not checked against the tenant — use composite foreign keys (tenantId, id) and/or RLS (rlsPolicySql + rls: true) as the database-level guarantee.
Parameters
options?
TenancyExtensionOptions & object
Returns
Call Signature
> tenancyExtension(options): TenancyRlsExtension
Defined in: prisma/src/extension.ts:504
Prisma client extension for the shared-database tenancy mode:
const db = new PrismaClient().$extends(tenancyExtension())
Every query on every model is scoped to ctx().tenant at call time — app code just writes db.project.findMany(). Operations it cannot scope (raw queries, unknown operations) are refused inside a tenant context.
Limits: a foreign-key SCALAR (data: { projectId }) is not checked against the tenant — use composite foreign keys (tenantId, id) and/or RLS (rlsPolicySql + rls: true) as the database-level guarantee.
Parameters
options
TenancyExtensionOptions & object
Returns
Call Signature
> tenancyExtension(options?): TenancyExtension | TenancyRlsExtension
Defined in: prisma/src/extension.ts:507
Prisma client extension for the shared-database tenancy mode:
const db = new PrismaClient().$extends(tenancyExtension())
Every query on every model is scoped to ctx().tenant at call time — app code just writes db.project.findMany(). Operations it cannot scope (raw queries, unknown operations) are refused inside a tenant context.
Limits: a foreign-key SCALAR (data: { projectId }) is not checked against the tenant — use composite foreign keys (tenantId, id) and/or RLS (rlsPolicySql + rls: true) as the database-level guarantee.