Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions examples/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,44 @@ 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()
.then((rows) => {
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();
})()
*/
8 changes: 4 additions & 4 deletions lib/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,7 +35,7 @@ class Rest {
return Rest.instance;
}

addStats(key, sfunc) {
addInfo(key, sfunc) {
this.info[key] = sfunc;
}

Expand All @@ -62,7 +62,7 @@ class Rest {

constructor() {
Rest.instance = this;

this.info = {};
this.logs = [];
this.name = 'REST Server';
Expand All @@ -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'));
Expand Down
2 changes: 2 additions & 0 deletions src/NuoJsAddon.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ using namespace v8;
#else
#define TRACE(msg)
#endif

#endif