Function: TenantId()
TenantId(
columnName?):PropertyDecorator
Defined in: src/decorators/TenantId.ts:20
Property decorator marking a field as the tenant discriminator identifier.
Entities with @TenantId() are automatically filtered by tenantId in queries (SELECT, UPDATE, DELETE),
and automatically populated on INSERT from the active context tenant configuration (ctx.forTenant(id)).
Parameters
| Parameter | Type | Description |
|---|---|---|
columnName? | string | Optional custom database column name (defaults to property name). |
Returns
PropertyDecorator
Usecase
Multi-tenant SaaS architectures requiring strict tenant data isolation.
Example
@Entity('customers')
class Customer {
@TenantId()
tenantId!: string;
}