basalt / prisma/src / CrossTenantSweepOptions
Interface: CrossTenantSweepOptions
Defined in: prisma/src/cross-tenant.ts:426
Properties
client?
> optional client?: unknown
Defined in: prisma/src/cross-tenant.ts:428
Prisma client used for the scan. Required unless scan is given.
columns?
> optional columns?: string[]
Defined in: prisma/src/cross-tenant.ts:434
Identifier columns besides tenant_id/id (see CrossTenantScanArgs.columns).
handle
> handle: (item, tenantId) => void | Promise<void>
Defined in: prisma/src/cross-tenant.ts:456
Processes one item, inside its tenant's context — so db(), the scoped client and RLS all apply as they do in a request. Must be idempotent: a sweep is an at-least-once safety net.
Parameters
item
tenantId
string
Returns
void | Promise<void>
limit?
> optional limit?: number
Defined in: prisma/src/cross-tenant.ts:458
Rows per page. Default 500.
maxItems?
> optional maxItems?: number
Defined in: prisma/src/cross-tenant.ts:460
Cap on the items one sweep processes. Default 10000.
onError?
> optional onError?: (error, item) => void
Defined in: prisma/src/cross-tenant.ts:472
An item's handle threw. Default: console.error. The next item still runs — one poisoned row must not stop the sweep. Must not throw.
Parameters
error
unknown
item
Returns
void
run?
> optional run?: (tenantId, fn) => Promise<void>
Defined in: prisma/src/cross-tenant.ts:467
Enters a tenant's context. Default: the tenant is put in the context directly (what tenancy.run does, minus the tenant lookup and the tenancy:switched hook). Pass (id, fn) => tenancy.run(id, fn) to get the real tenant record and the hook — the usual wiring in an app.
Parameters
tenantId
string
fn
() => Promise<void>
Returns
Promise<void>
scan?
> optional scan?: (page) => CrossTenantScanRow[] | Promise<CrossTenantScanRow[]>
Defined in: prisma/src/cross-tenant.ts:450
Replaces the function call with a query of your own — what a deployment without RLS uses: a central client can select the identifiers directly, and no SQL function is needed.
scan: ({ limit, after }) => central.job.findMany({
where: { status: 'PROCESSING', ...(after ? { OR: [...] } : {}) },
select: { tenantId: true, id: true },
orderBy: [{ tenantId: 'asc' }, { id: 'asc' }],
take: limit,
})
Must return rows ordered by (tenantId, id) and resume strictly after after, or the sweep will loop over the same page.
Parameters
page
Returns
CrossTenantScanRow[] | Promise<CrossTenantScanRow[]>
scanFunction?
> optional scanFunction?: string
Defined in: prisma/src/cross-tenant.ts:430
Name of the function generated by crossTenantScanSql.
schema?
> optional schema?: string
Defined in: prisma/src/cross-tenant.ts:432
Schema of that function. Default: 'public'.