leo-connector-common
Advanced tools
Comparing version 1.1.5 to 1.2.0
@@ -33,7 +33,5 @@ "use strict"; | ||
// if we're doing a snapshot, put the table and id into the connection object | ||
if (params.snapshot) { | ||
params.connection.table = params.table; | ||
params.connection.id = params.pk; | ||
} | ||
// put the table and id into the connection object if we haven't already done so | ||
params.connection.table = params.connection.table || params.table; | ||
params.connection.id = params.connection.id || params.pk; | ||
@@ -78,4 +76,15 @@ let tables = {}, | ||
if (Array.isArray(tables[table])) { // if we passed in an array of primary keys | ||
// turn the object into an array of items | ||
objArray.push(obj[table].map(row => { | ||
let array = []; | ||
for (let key of tables[table]) { | ||
array.push(row[key]); | ||
} | ||
return array; | ||
})); | ||
// if the value of any of the tables is a SELECT query, replace ? with the IDs in obj[table] | ||
if (tables[table].match(/^SELECT/)) { | ||
} else if (tables[table].match(/^SELECT/)) { | ||
async.doWhilst((done) => { | ||
@@ -98,3 +107,7 @@ | ||
function (ids, builder) { | ||
let idsList = ids.filter(id => {return id != undefined}).join(); | ||
let idsList = ids; | ||
if (Array.isArray(ids)) { | ||
idsList = ids.filter(id => {return id != undefined}).join(); | ||
} | ||
let builderSql = builder(params.pk, sqlQuery.replace(/\?/g, idsList)); | ||
@@ -101,0 +114,0 @@ |
{ | ||
"name": "leo-connector-common", | ||
"version": "1.1.5", | ||
"version": "1.2.0", | ||
"description": "Common package for all Leo Platform database connectors", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
92857
3412