@bee.js/node 0.0.87 → 0.0.89
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/beehive.js +27 -24
- package/package.json +1 -1
package/beehive.js
CHANGED
|
@@ -253,38 +253,41 @@ module.exports = function hive(req = {}, res = {}, model = null) {
|
|
|
253
253
|
},
|
|
254
254
|
|
|
255
255
|
whereIf: function (condition, where, binds) {
|
|
256
|
-
if (condition)
|
|
256
|
+
if (!condition) return;
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
script[0]["where"].push(typeof where == "function" ? where() : where);
|
|
259
|
+
|
|
260
|
+
if (binds)
|
|
259
261
|
script[0]["binds"].push(typeof binds === "function" ? binds() : binds);
|
|
260
262
|
|
|
261
263
|
return this;
|
|
262
264
|
},
|
|
263
265
|
|
|
264
266
|
whereIn: function (field, array = []) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
].join(",");
|
|
267
|
+
const values = {};
|
|
268
|
+
|
|
269
|
+
array.map((row) => {
|
|
270
|
+
const val = row[field];
|
|
271
|
+
|
|
272
|
+
if (!!!val) return;
|
|
273
|
+
|
|
274
|
+
switch (model.schema[field]?.type) {
|
|
275
|
+
case "char":
|
|
276
|
+
case "varchar":
|
|
277
|
+
case "text":
|
|
278
|
+
case "string":
|
|
279
|
+
return (values[`'${val}'`] = true);
|
|
280
|
+
case "guid":
|
|
281
|
+
case "uuid":
|
|
282
|
+
return (values[beeTools.guidToBin(val) ?? "null"] = true);
|
|
283
|
+
default:
|
|
284
|
+
return (values[val] = true);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
286
287
|
|
|
287
|
-
script[0]["where"].push(
|
|
288
|
+
script[0]["where"].push(
|
|
289
|
+
`${model.table}.${field} IN(${Object.keys(values).join(",") ?? "null"})`
|
|
290
|
+
);
|
|
288
291
|
|
|
289
292
|
return this;
|
|
290
293
|
},
|