Skip to content

db/repository

Documentation

Overview

Classes

Repository

getEntityName()

ts
getEntityName(): string;

Returns

  • Type: string
  • Description:

getTableName()

ts
getTableName(): string;

Returns

  • Type: string
  • Description:

getIdName()

ts
getIdName(): string;

Returns

  • Type: string
  • Description:

getIdColumn()

ts
getIdColumn(): string;

Returns

  • Type: string
  • Description:

findAll()

Finds all entities matching the given options.

ts
findAll(options: Options): void;
ParameterTypeDescription
optionsOptions

Returns

  • Type: void
  • Description:

findById()

Finds a single entity by its primary key ID.

ts
findById(id: any, options: Options): T;
ParameterTypeDescription
idany
optionsOptions

Returns

  • Type: T
  • Description:

create()

Creates a new entity in the database.

ts
create(entity: T): void;
ParameterTypeDescription
entityT

Returns

  • Type: void
  • Description: The generated ID (string or number).

update()

Updates an existing entity. The entity must contain the primary key.

ts
update(entity: T): void;
ParameterTypeDescription
entityT

Returns

  • Type: void
  • Description:

upsert()

Creates the entity if the ID is null/undefined, otherwise updates it. If an ID is provided but the entity doesn't exist, it creates it.

ts
upsert(entity: T): void;
ParameterTypeDescription
entityT

Returns

  • Type: void
  • Description: The entity's ID.

deleteById()

Deletes an entity by its primary key ID.

ts
deleteById(id: any): void;
ParameterTypeDescription
idany

Returns

  • Type: void
  • Description:

count()

Counts the number of entities matching the given options.

ts
count(options: Options): number;
ParameterTypeDescription
optionsOptions

Returns

  • Type: number
  • Description:

triggerEvent()

Protected method intended for subclass overriding or internal event handling.

ts
triggerEvent(_data: EntityEvent): Promise;
ParameterTypeDescription
_dataEntityEvent

Returns

  • Type: Promise
  • Description: