Setu-TS
    Preparing search index...

    Interface ITenantDataStore

    Tenant-scoped data-store port.

    Implemented by the multi-tenancy plugin's shipped MemoryTenantDataStore (zero-dependency default), by database-plugin's DatabaseTenantDataStore (the bridge over IDatabaseService, M101c V8-8), and by application- provided backends that consume real databases.

    Promoted from @setu-ts/multi-tenancy-plugin to common so a package that implements a store (database-plugin) can name the port without importing the plugin that declares its consumer (AI_GUIDELINES §2.2); the plugin re-exports the type so existing imports keep compiling.

    0.9.0

    interface ITenantDataStore {
        close?(): Promise<void>;
        create<E>(
            tenantId: string,
            entity: string,
            data: Readonly<Record<string, unknown>>,
        ): Promise<E>;
        delete<Id>(tenantId: string, entity: string, id: Id): Promise<boolean>;
        find<E>(
            tenantId: string,
            entity: string,
            filter: Readonly<Record<string, unknown>>,
        ): Promise<readonly E[]>;
        findAll<E>(tenantId: string, entity: string): Promise<readonly E[]>;
        findById<E, Id>(
            tenantId: string,
            entity: string,
            id: Id,
        ): Promise<E | null>;
        update<E, Id>(
            tenantId: string,
            entity: string,
            id: Id,
            data: Readonly<Record<string, unknown>>,
        ): Promise<E | null>;
        useIsolation?(strategy: ITenantIsolationStrategy): void;
    }

    Implemented by

    Index
    • Create a new record; returns the stored entity including its id.

      Type Parameters

      • E

      Parameters

      • tenantId: string
      • entity: string
      • data: Readonly<Record<string, unknown>>

      Returns Promise<E>

    • Delete a record. Returns true if a record was deleted.

      Type Parameters

      • Id

      Parameters

      • tenantId: string
      • entity: string
      • id: Id

      Returns Promise<boolean>

    • Find records matching a filter.

      Type Parameters

      • E

      Parameters

      • tenantId: string
      • entity: string
      • filter: Readonly<Record<string, unknown>>

      Returns Promise<readonly E[]>

    • Retrieve all records of an entity for a tenant.

      Type Parameters

      • E

      Parameters

      • tenantId: string
      • entity: string

      Returns Promise<readonly E[]>

    • Find a single record by its identifier.

      Type Parameters

      • E
      • Id

      Parameters

      • tenantId: string
      • entity: string
      • id: Id

      Returns Promise<E | null>

    • Update an existing record; returns null when the id is unknown.

      Type Parameters

      • E
      • Id

      Parameters

      • tenantId: string
      • entity: string
      • id: Id
      • data: Readonly<Record<string, unknown>>

      Returns Promise<E | null>