diff --git a/examples/query.js b/examples/query.js index 91290ee..86f7542 100644 --- a/examples/query.js +++ b/examples/query.js @@ -9,9 +9,9 @@ const { Driver } = require('..'); const config = require('../test/config'); var driver = new Driver(); - driver.connect(config) .then((conn) => { + conn.autoCommit = false; conn.execute('select tablename from system.tables') .then((results) => { results.getRows() @@ -19,18 +19,34 @@ driver.connect(config) console.log(rows); }); }); + conn.commit(); }); // async variation -/* -async function query(conn, sql) { - let results = await conn.execute(sql); +async function query(conn, sql, params) { + let results = await conn.execute(sql,params); return await results.getRows(); } (async () => { let conn = await driver.connect(config); - let rows = await query(conn, 'select tablename from system.tables'); - console.log(rows); + console.log(conn.autoCommit); + conn.autoCommit = true; + console.log(conn.autoCommit); + await conn.execute("start transaction"); + let results = await conn.execute('select tablename from system.tables limit 2'); + let rows = await results.getRows(); + for (let i = 0; i < rows.length; i++) { + let results1 = await conn.execute("select field from system.fields where tablename = ? limit 2",[rows[i].TABLENAME]); + let rows1 = await results1.getRows(); + for (let j = 0; j < rows1.length; j++) { + console.log(rows[i].TABLENAME,rows1[j].FIELD); + } + results1.close(); + } + results.close(); + conn.commit(); +// await conn.execute("commit"); + console.log(conn.autoCommit); + conn.close(); })() -*/ diff --git a/lib/rest.js b/lib/rest.js index a633441..8cf81fa 100644 --- a/lib/rest.js +++ b/lib/rest.js @@ -14,7 +14,7 @@ var port = 9000; if (process.env[portVarName] && process.env[portVarName].trim() !== '') { const parsedValue = Number(process.env[portVarName]); if (isNaN(parsedValue) || !Number.isInteger(parsedValue)) { - console.error(`Error: Environment variable ${portVarName} has an invalid integer value: "${process.env[portVarName}".`); + console.error(`Error: Environment variable ${portVarName} has an invalid integer value: ${process.env[portVarName]}.`); process.exit(1); } port = parsedValue; @@ -35,7 +35,7 @@ class Rest { return Rest.instance; } - addStats(key, sfunc) { + addInfo(key, sfunc) { this.info[key] = sfunc; } @@ -62,7 +62,7 @@ class Rest { constructor() { Rest.instance = this; - + this.info = {}; this.logs = []; this.name = 'REST Server'; @@ -83,7 +83,7 @@ class Rest { }); // Add all supported URL command paths - + this._express.get('/shutdown', (req, res) => { this.gracefulShutdown(); res.send(JSON.stringify('OK')); diff --git a/src/NuoJsAddon.h b/src/NuoJsAddon.h index e4a71a9..4a53236 100644 --- a/src/NuoJsAddon.h +++ b/src/NuoJsAddon.h @@ -35,3 +35,5 @@ using namespace v8; #else #define TRACE(msg) #endif + +#endif