zet-lib 1.0.41 → 1.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/connection.js +7 -3
- package/lib/zRoute.js +6 -4
- package/package.json +1 -1
package/lib/connection.js
CHANGED
|
@@ -138,13 +138,15 @@ connection.insert = async(obj) => {
|
|
|
138
138
|
const datas = [];
|
|
139
139
|
const values = [];
|
|
140
140
|
const arr = [];
|
|
141
|
+
const returning = data.returning || 'RETURNING *'
|
|
142
|
+
delete data.returning;
|
|
141
143
|
for (const key in data) {
|
|
142
144
|
datas.push(key);
|
|
143
145
|
values.push(`$${increment}`)
|
|
144
146
|
arr.push(data[key]);
|
|
145
147
|
increment++;
|
|
146
148
|
}
|
|
147
|
-
const sql = `INSERT INTO "${table}" ("${datas.join('","')}") VALUES (${values.join(",")})
|
|
149
|
+
const sql = `INSERT INTO "${table}" ("${datas.join('","')}") VALUES (${values.join(",")}) ${returning}`;
|
|
148
150
|
/* console.log("ON INSERT " + sql)
|
|
149
151
|
console.log(arr)
|
|
150
152
|
*/
|
|
@@ -163,6 +165,9 @@ connection.insert = async(obj) => {
|
|
|
163
165
|
connection.update = async(obj) => {
|
|
164
166
|
const table = obj.table;
|
|
165
167
|
const data = obj.data;
|
|
168
|
+
const returning = data.returning || 'RETURNING *'
|
|
169
|
+
delete data.returning;
|
|
170
|
+
|
|
166
171
|
const where = obj.where || {}
|
|
167
172
|
//[{field:"your_field",option:"=>",value:"12",operator:"AND"}]
|
|
168
173
|
let whereArray = obj.whereArray || [];
|
|
@@ -194,7 +199,7 @@ connection.update = async(obj) => {
|
|
|
194
199
|
wherequery = wherequery.slice(0, -5);
|
|
195
200
|
}
|
|
196
201
|
const wheres = arr.length ? " WHERE " + wherequery : "";
|
|
197
|
-
const sql = `UPDATE "${table}" SET ${dataArr.join(", ")} ${wheres}
|
|
202
|
+
const sql = `UPDATE "${table}" SET ${dataArr.join(", ")} ${wheres} ${returning}`;
|
|
198
203
|
/* console.log(sql);
|
|
199
204
|
console.log(arr);*/
|
|
200
205
|
try {
|
|
@@ -287,7 +292,6 @@ connection.constraintList = (table, schema = "public") => {
|
|
|
287
292
|
INNER JOIN pg_catalog.pg_namespace nsp
|
|
288
293
|
ON nsp.oid = connamespace
|
|
289
294
|
WHERE nsp.nspname = '${schema}' AND rel.relname = '${table}'; `;
|
|
290
|
-
|
|
291
295
|
}
|
|
292
296
|
|
|
293
297
|
var toNumber = function (num) {
|
package/lib/zRoute.js
CHANGED
|
@@ -3288,11 +3288,13 @@ zRoute.modelsCache = async() => {
|
|
|
3288
3288
|
const splits = key.split("___") || [];
|
|
3289
3289
|
let item = splits.length > 1 ? splits[1] : key;
|
|
3290
3290
|
let arr = [];
|
|
3291
|
-
|
|
3292
|
-
|
|
3291
|
+
if(results.length) {
|
|
3292
|
+
for (const result of results) {
|
|
3293
|
+
arr.push({id: result.id, zname: result[item]});
|
|
3294
|
+
}
|
|
3295
|
+
const myarray = Util.sortArray(arr, 'zname');
|
|
3296
|
+
myCache.set(`${keys}_${key}_${company.id}`, myarray);
|
|
3293
3297
|
}
|
|
3294
|
-
const myarray = Util.sortArray(arr, 'zname');
|
|
3295
|
-
myCache.set(`${keys}_${key}_${company.id}`, myarray);
|
|
3296
3298
|
}
|
|
3297
3299
|
}
|
|
3298
3300
|
}
|