A factory the multi-tenancy plugin resolves in onInit
import { DatabasePlugin, createDatabaseTenantDataStore } from '@setu-ts/database-plugin';
import { MultiTenancyPlugin } from '@setu-ts/multi-tenancy-plugin';
const app = createApplication({
plugins: [
DatabasePlugin({ type: 'memory' }),
MultiTenancyPlugin({
resolver: 'header',
dataStore: createDatabaseTenantDataStore(),
}),
],
});
Builds the tenant data-store bridge as a
RegistryFactory, for the multi-tenancy plugin'sdataStoreoption.The returned factory resolves
CAPABILITIES.DATABASEfrom the registry it is handed — typed asIDatabaseService, the token's documented interface — and returns aDatabaseTenantDataStoreover it. Resolving atonInit(notregister()) is what letsDatabasePluginbe registered after the tenancy plugin: everyregister()phase completes before anyonInit, so no ordering edge is needed.The tenant column comes from the plugin's isolation strategy, which the plugin always hands the store:
'column-per-tenant'uses'tenant_id', anddatabase: new ColumnPerTenant('org_id')names another column. There is no second place to name it, so the two cannot disagree.