interface ITenantRepository
Since 0.1.0

Tenant-scoped repository — delegates CRUD to the data store the multi-tenancy plugin was configured with (ITenantDataStore, declared in that plugin), while threading the resolved tenant id.

Type Parameters

Entity
Id = string

Methods

findAll(): Promise<readonly Entity[]>

Retrieve all records.

findById(id: Id): Promise<Entity | null>

Find a single record by its identifier.

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

Find records matching a filter.

create(data: Readonly<Record<string, unknown>>): Promise<Entity>

Create a new record.

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

Update an existing record by its identifier.

delete(id: Id): Promise<boolean>

Delete a record by its identifier. Returns true if a record was deleted.

Usage

import { type ITenantRepository } from "common/src/index.ts";