Skip to main content
zerotal

Documentation


Documentation / @zerotal/orm / index / ContextConnectionResolver

Type Alias: ContextConnectionResolver

ContextConnectionResolver = (ModelClass?) => SQLInstance | null

Defined in: packages/orm/src/model/BaseModel.ts:153

Context-aware connection resolver — an additive, AsyncLocalStorage-safe hook used by features that route queries to a connection chosen by the current execution context rather than a global override. The canonical user is @zerotal/tenancy's multi-database strategy: it returns the active tenant's connection so every model query transparently hits the right database. Returns null to defer to the normal resolution. Defaults to a no-op, so it changes nothing until something registers it.

Parameters

ModelClass?

typeof BaseModel

Returns

SQLInstance | null