db/repository
Documentation
- source: db/repository.ts
Overview
Classes
Repository
getEntityName()
tsgetEntityName(): string;Returns
- Type:
string- Description:
getTableName()
tsgetTableName(): string;Returns
- Type:
string- Description:
getIdName()
tsgetIdName(): string;Returns
- Type:
string- Description:
getIdColumn()
tsgetIdColumn(): string;Returns
- Type:
string- Description:
findAll()
Finds all entities matching the given options.
tsfindAll(options: Options): void;
Parameter Type Description optionsOptionsReturns
- Type:
void- Description:
findById()
Finds a single entity by its primary key ID.
tsfindById(id: any, options: Options): T;
Parameter Type Description idanyoptionsOptionsReturns
- Type:
T- Description:
create()
Creates a new entity in the database.
tscreate(entity: T): void;
Parameter Type Description entityTReturns
- Type:
void- Description: The generated ID (string or number).
update()
Updates an existing entity. The entity must contain the primary key.
tsupdate(entity: T): void;
Parameter Type Description entityTReturns
- 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.
tsupsert(entity: T): void;
Parameter Type Description entityTReturns
- Type:
void- Description: The entity's ID.
deleteById()
Deletes an entity by its primary key ID.
tsdeleteById(id: any): void;
Parameter Type Description idanyReturns
- Type:
void- Description:
count()
Counts the number of entities matching the given options.
tscount(options: Options): number;
Parameter Type Description optionsOptionsReturns
- Type:
number- Description:
triggerEvent()
Protected method intended for subclass overriding or internal event handling.
tstriggerEvent(_data: EntityEvent): Promise;
Parameter Type Description _dataEntityEventReturns
- Type:
Promise- Description:
