class MemoryTenantDataStore
implements ITenantDataStore

A zero-dependency in-memory ITenantDataStore that partitions rows by strategy-derived scope ('column' → tenantId, 'schema' → resolved schema, 'database' → resolved database).

When useIsolation was never called (bare construction), scope defaults to the raw tenantId.

Constructors

MemoryTenantDataStore(options?: MemoryTenantDataStoreOptions)

Methods

close(): Promise<void>

Gracefully close any connections.

create<E>(
tenantId: string,
entity: string,
data: Readonly<Record<string, unknown>>
): Promise<E>

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

delete<Id>(
tenantId: string,
entity: string,
id: Id
): Promise<boolean>

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

find<E>(
tenantId: string,
entity: string,
filter: Readonly<Record<string, unknown>>
): Promise<readonly E[]>

Find records matching a filter.

findAll<E>(
tenantId: string,
entity: string
): Promise<readonly E[]>

Retrieve all records of an entity for a tenant.

findById<E, Id>(
tenantId: string,
entity: string,
id: Id
): Promise<E | null>

Find a single record by its identifier.

update<E, Id>(
tenantId: string,
entity: string,
id: Id,
data: Readonly<Record<string, unknown>>
): Promise<E | null>

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

Receive the isolation strategy from the plugin's register().

Usage

import { MemoryTenantDataStore } from "multi-tenancy-plugin/src/index.ts";