Setu-TS
    Preparing search index...

    Function createDatabaseTenantDataStore

    • Builds the tenant data-store bridge as a RegistryFactory, for the multi-tenancy plugin's dataStore option.

      The returned factory resolves CAPABILITIES.DATABASE from the registry it is handed — typed as IDatabaseService, the token's documented interface — and returns a DatabaseTenantDataStore over it. Resolving at onInit (not register()) is what lets DatabasePlugin be registered after the tenancy plugin: every register() phase completes before any onInit, 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', and database: new ColumnPerTenant('org_id') names another column. There is no second place to name it, so the two cannot disagree.

      Returns RegistryFactory<ITenantDataStore>

      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(),
      }),
      ],
      });

      0.9.0