mysql-rest
Advanced tools
Comparing version 0.6.7 to 0.6.8
@@ -1340,2 +1340,6 @@ "use strict"; | ||
let ids = [].concat(results).map((o) => o[items[0]]); | ||
ids = lodash.compact(lodash.uniq(ids)); | ||
if (ids.length === 0) { | ||
return; | ||
} | ||
let sql = ` | ||
@@ -1349,3 +1353,3 @@ SELECT ${items[2]} FROM ${items[1]} | ||
results.map((o) => { | ||
o[items[3]] = refs.includes(o[items[0]]); | ||
o[items[3]] = (refs || []).includes(o[items[0]]); | ||
return o; | ||
@@ -1361,10 +1365,19 @@ }); | ||
let ids = [].concat(results).map((o) => o[items[0]]); | ||
ids = lodash.compact(lodash.uniq(ids)); | ||
if (ids.length === 0) { | ||
return; | ||
} | ||
let sql = ` | ||
SELECT * FROM ${items[1]} | ||
WHERE ${items[2]} IN (${lodash.uniq(ids).join(",")}); | ||
WHERE ${items[2]} IN (${ids.join(",")}); | ||
`; | ||
let includeResults = await this.exec(sql, []); | ||
if (includeResults.length === 0) { | ||
return; | ||
} | ||
results.map((o) => { | ||
let foud = includeResults.filter((i) => i[items[2]] === o[items[0]]); | ||
o[items[0]] = foud.length > 0 ? foud[0] : null; | ||
if (foud.length > 0) { | ||
o[items[0]] = foud[0]; | ||
} | ||
return o; | ||
@@ -1371,0 +1384,0 @@ }); |
{ | ||
"name": "mysql-rest", | ||
"version": "0.6.7", | ||
"version": "0.6.8", | ||
"description": "One command to generate REST APIs for any MySql database, support multi databases", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2131040
4831