Skip to content

Configuration

switchTenant()

switchTenant() — returns void

Available in: controller, model, mapper, migrator, migration, tabledefinition Category: Multi-Tenancy

Switches the active tenant mid-request. Throws if the current tenant is locked (set by TenantResolver middleware) unless force is true.

NameTypeRequiredDefaultDescription
tenantstructyesStruct with at minimum a dataSource key. Optional: id, config.
forcebooleannofalseIf true, overrides the lock set by TenantResolver middleware.