Skip to content

db/store

Documentation

Overview

Classes

Store

save()

Saves a new entry to the data store.

ts
static save(name: string, entry: any): void;
ParameterTypeDescription
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.

ts
static upsert(name: string, entry: any): void;
ParameterTypeDescription
namestringThe entity/table name.
entryanyThe JavaScript object to insert/update.

Returns

  • Type: void
  • Description:

update()

Updates an existing entry.

ts
static update(name: string, entry: any): void;
ParameterTypeDescription
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.

ts
static list(name: string, options: Options): void;
ParameterTypeDescription
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.

ts
static count(name: string, options: Options): number;
ParameterTypeDescription
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.

ts
static get(name: string, id: any): any;
ParameterTypeDescription
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.

ts
static remove(name: string, id: any): void;
ParameterTypeDescription
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).

ts
static find(name: string, example: any, limit: number, offset: number): void;
ParameterTypeDescription
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.

ts
static query(query: string, parameters: any, limit: number, offset: number): void;
ParameterTypeDescription
querystringThe query script.
parametersany
limitnumberMaximum 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.

ts
static queryNative(query: string, parameters: any, limit: number, offset: number): void;
ParameterTypeDescription
querystringThe entity/table name.
parametersany
limitnumber
offsetnumber

Returns

  • Type: void
  • Description: An array of all JavaScript objects.

getEntityName()

Gets the name of the entity associated with the store name.

ts
static getEntityName(name: string): string;
ParameterTypeDescription
namestring

Returns

  • Type: string
  • Description:

getTableName()

Gets the underlying database table name for the entity.

ts
static getTableName(name: string): string;
ParameterTypeDescription
namestring

Returns

  • Type: string
  • Description:

getIdName()

Gets the property name used as the ID field in the entity object.

ts
static getIdName(name: string): string;
ParameterTypeDescription
namestring

Returns

  • Type: string
  • Description:

getIdColumn()

Gets the underlying database column name used for the ID field.

ts
static getIdColumn(name: string): string;
ParameterTypeDescription
namestring

Returns

  • Type: string
  • Description: