Database Update

Simplified update functionality, accepts SQL script and query parameters and returns the result-set as a JSON object.

Version 3.x

Basic Usage

1
2
3
4
5
6
var update = require('db/v3/update');

update.execute("CREATE TABLE MY_TABLE (COLUMN_A INT, COLUMN_B VARCHAR(10))");
update.execute("INSERT INTO MY_TABLE VALUES (1, 'ABC')");
update.execute("INSERT INTO MY_TABLE VALUES (2, 'DEF')");
update.execute("DROP TABLE MY_TABLE");

Definition

Functions


Function Description Returns
execute(sql, parameters?, databaseType?, datasourceName?) Executes a SQL update against the selected databaseType and datasourceName with the provided parameters and returns the number of affected rows int

parameters array supports primitives e.g. [1, โ€˜Johnโ€™, 34.56] or objects in format {โ€˜typeโ€™:โ€™[DATA_TYPE]โ€™, โ€˜valueโ€™:[VALUE]} e.g. [1, {โ€˜typeโ€™:โ€™CHARโ€™, โ€˜valueโ€™:โ€™ISBN19202323322โ€™}]

Compatibility

Rhino Nashorn V8
โœ… โœ… โœ…


Edit