Skip to content

db/query

Documentation

Overview

Classes

Query

execute()

Executes a standard SQL query with positional parameters. Parameters array supports primitives e.g. `[1, 'John', 34.56]` or objects in format either `{'type':'[DATA_TYPE]', 'value':[VALUE]}` or `{'name':'[string]', 'type':'[DATA_TYPE]', 'value':[VALUE]}` e.g. `[{'type':'CHAR', 'value':'ISBN19202323322'}]` or `[{'name': 'order_number', 'type':'CHAR', 'value':'ISBN19202323322'}]`

ts
static execute(sql: string, parameters: any, datasourceName: string, formatting: FormattingParameter): void;
ParameterTypeDescription
sqlstringThe SQL query to execute.
parametersanyAn optional array of values (primitives, TypedQueryParameter or NamedQueryParameter objects) to replace '?' or :paramName placeholders.
datasourceNamestringThe name of the database connection to use (optional).
formattingFormattingParameterOptional formatting parameters for the result set (e.g., date format).

Returns

  • Type: void
  • Description: An array of records representing the query results.

executeNamed()

Executes a SQL query with named parameters (e.g., ":name", ":id").

ts
static executeNamed(sql: string, parameters: any, datasourceName: string): void;
ParameterTypeDescription
sqlstringThe SQL query to execute.
parametersanyAn optional array of NamedQueryParameter objects.
datasourceNamestringThe name of the database connection to use (optional).

Returns

  • Type: void
  • Description: An array of records representing the query results.