انتقل إلى المحتوى الرئيسي

Class: PlatformRepository<DB, T>

Defined in: packages/persistence/src/platform.ts:105

The repository for operations that precede a tenant or exceed one. Every method takes a PlatformScope; a tenant Scope does not compile. There is no subtree predicate: the scope names none, and a platform operation addresses rows by identity (a principal's (issuer, sub), the organization bootstrap creates).

It is separate from TenantRepository and shares none of its type, so no repository can accept both by accident.

Type Parameters​

DB​

DB

T​

T extends keyof DB & string

Constructors​

Constructor​

new PlatformRepository<DB, T>(db, options): PlatformRepository<DB, T>

Defined in: packages/persistence/src/platform.ts:113

Parameters​

db​

Database<DB>

The module's pool.

options​

PlatformTableOptions<T>

The table and its id and path columns.

Returns​

PlatformRepository<DB, T>

Methods​

find()​

find(on, filter?, limit?): Promise<Selectable<DB[T]>[]>

Defined in: packages/persistence/src/platform.ts:149

Parameters​

on​

PlatformScopeOrTransaction<DB>

Platform scope, or the open transaction.

filter?​

Partial<Selectable<DB[T]>> = {}

Column equalities; null matches NULL.

limit?​

number

At most this many rows, capped at 1000. Default 100.

Returns​

Promise<Selectable<DB[T]>[]>

Matching rows, by id.


findById()​

findById(on, id): Promise<Selectable<DB[T]> | undefined>

Defined in: packages/persistence/src/platform.ts:172

Parameters​

on​

PlatformScopeOrTransaction<DB>

Platform scope, or the open transaction.

id​

unknown

The row id.

Returns​

Promise<Selectable<DB[T]> | undefined>

The row, or undefined.


insert()​

insert(on, row): Promise<Selectable<DB[T]>>

Defined in: packages/persistence/src/platform.ts:193

Inserts one row and returns it as stored, defaults and generated columns filled.

Parameters​

on​

PlatformScopeOrTransaction<DB>

Platform scope, or the open transaction.

row​

Insertable<DB[T]>

Returns​

Promise<Selectable<DB[T]>>


scoped()​

protected scoped<R>(on, work): Promise<R>

Defined in: packages/persistence/src/platform.ts:129

Runs custom work under a platform scope.

Type Parameters​

R​

R

Parameters​

on​

PlatformScopeOrTransaction<DB>

A platform scope, or the transaction to join.

work​

(tx) => Promise<R>

Receives the platform transaction.

Returns​

Promise<R>

What work returned.


update()​

update(on, id, patch): Promise<Selectable<DB[T]> | undefined>

Defined in: packages/persistence/src/platform.ts:215

Parameters​

on​

PlatformScopeOrTransaction<DB>

Platform scope, or the open transaction.

id​

unknown

The row id.

patch​

Updateable<DB[T]>

Columns to change; never the id or the path.

Returns​

Promise<Selectable<DB[T]> | undefined>

The updated row, or undefined when absent.

Throws​

immutable_column when the patch names the id or path.