db/store
Documentation
- source: db/store.ts
Overview
Classes
Store
save()
Saves a new entry to the data store.
tsstatic save(name: string, entry: any): void;
Parameter Type Description namestringThe entity/table name. entryanyThe JavaScript object to save. Returns
- Type:
void- Description: The ID of the newly created entry (string or number).
upsert()
Inserts a new entry or updates an existing one if the ID is present.
tsstatic upsert(name: string, entry: any): void;
Parameter Type Description namestringThe entity/table name. entryanyThe JavaScript object to insert/update. Returns
- Type:
void- Description:
update()
Updates an existing entry.
tsstatic update(name: string, entry: any): void;
Parameter Type Description namestringThe entity/table name. entryanyThe JavaScript object with the ID and updated data. Returns
- Type:
void- Description:
list()
Lists entries based on optional filtering, sorting, and pagination options.
tsstatic list(name: string, options: Options): void;
Parameter Type Description namestringThe entity/table name. optionsOptionsOptional Options for query execution. Returns
- Type:
void- Description: An array of JavaScript objects.
count()
Counts the number of entries based on optional filtering options.
tsstatic count(name: string, options: Options): number;
Parameter Type Description namestringThe entity/table name. optionsOptionsOptional Options for query execution. Returns
- Type:
number- Description: The count of matching entries.
get()
Retrieves a single entry by its ID.
tsstatic get(name: string, id: any): any;
Parameter Type Description namestringThe entity/table name. idanyThe ID of the entry. Returns
- Type:
any- Description: The entry object, or undefined if not found.
remove()
Deletes an entry by its ID.
tsstatic remove(name: string, id: any): void;
Parameter Type Description namestringThe entity/table name. idanyThe ID of the entry to remove. Returns
- Type:
void- Description:
find()
Finds entries matching an example object (query-by-example).
tsstatic find(name: string, example: any, limit: number, offset: number): void;
Parameter Type Description namestringThe entity/table name. exampleanyAn object containing properties to match. limitnumberMaximum number of results to return. offsetnumberNumber of results to skip. Returns
- Type:
void- Description: An array of matching JavaScript objects.
query()
Queries all entries for a given script with pagination.
tsstatic query(query: string, parameters: any, limit: number, offset: number): void;
Parameter Type Description querystringThe query script. parametersanylimitnumberMaximum number of results to return. offsetnumberNumber of results to skip. Returns
- Type:
void- Description: An array of JavaScript objects.
queryNative()
Queries all entries for a given entity name without pagination.
tsstatic queryNative(query: string, parameters: any, limit: number, offset: number): void;
Parameter Type Description querystringThe entity/table name. parametersanylimitnumberoffsetnumberReturns
- Type:
void- Description: An array of all JavaScript objects.
getEntityName()
Gets the name of the entity associated with the store name.
tsstatic getEntityName(name: string): string;
Parameter Type Description namestringReturns
- Type:
string- Description:
getTableName()
Gets the underlying database table name for the entity.
tsstatic getTableName(name: string): string;
Parameter Type Description namestringReturns
- Type:
string- Description:
getIdName()
Gets the property name used as the ID field in the entity object.
tsstatic getIdName(name: string): string;
Parameter Type Description namestringReturns
- Type:
string- Description:
getIdColumn()
Gets the underlying database column name used for the ID field.
tsstatic getIdColumn(name: string): string;
Parameter Type Description namestringReturns
- Type:
string- Description:
