Skip to content

db/insert

Documentation

Overview

Classes

Insert

execute()

Executes a single parameterized INSERT statement. *

ts
static execute(sql: string, parameters: any, datasourceName: string): void;
ParameterTypeDescription
sqlstringThe SQL query to execute, with '?' placeholders for parameters.
parametersanyAn optional array of values to replace the '?' placeholders.
datasourceNamestringThe name of the database connection to use (optional).

Returns

  • Type: void
  • Description: An array of records representing the result of the insertion (e.g., generated keys).

executeMany()

Executes multiple parameterized INSERT statements as a batch operation. *

ts
static executeMany(sql: string, parameters: any, datasourceName: string): void;
ParameterTypeDescription
sqlstringThe SQL query to execute, with '?' placeholders for parameters.
parametersanyAn optional array of parameter arrays, where each inner array corresponds to one execution of the SQL statement.
datasourceNamestringThe name of the database connection to use (optional).

Returns

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