@bee.js/node 0.0.32 → 0.0.36

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 CHANGED
@@ -243,6 +243,31 @@ module.exports = function hive(req = {}, res = {}, model = null) {
243
243
  return this
244
244
  },
245
245
 
246
+ whereIn: function(field, array = []) {
247
+ array = array
248
+ .map(row => {
249
+ let val = row[field]
250
+
251
+ switch (model.schema[field].type) {
252
+ case "char":
253
+ case "varchar":
254
+ case "text":
255
+ case "string":
256
+ return `'${val}'`
257
+ case "guid":
258
+ case "uuid":
259
+ return val ? beeTools.guidToBin(val) : null
260
+ default:
261
+ return val
262
+ }
263
+ })
264
+ .join(",")
265
+
266
+ script[0]['where'].push(`${model.table}.${field} IN(${array})`)
267
+
268
+ return this
269
+ },
270
+
246
271
  binds: function(...params) {
247
272
 
248
273
  params.map(bind=> script[0]['binds'].push(bind))
@@ -378,6 +403,9 @@ module.exports = function hive(req = {}, res = {}, model = null) {
378
403
 
379
404
  SQL = 'DELETE FROM ' + q(model.table)
380
405
  SQL += beeORM.modelSqlWhere(model, ids, req.middleware)
406
+ SQL += script[0]['where'].length
407
+ ? (!ids.length ? ' WHERE ' : ' AND ') + script[0]['where'].join(" AND ")
408
+ : ''
381
409
 
382
410
  data = await dbExec(SQL)
383
411
 
package/lib/JWT/beeJWT.js CHANGED
@@ -1,9 +1,11 @@
1
1
  const crypto = require('crypto')
2
2
  const log = require('../beeHive/log')
3
3
 
4
- module.exports = function token(payload = null, header = {}) {
4
+ module.exports = function token(_payload = null, header = {}) {
5
5
 
6
- if(payload) {
6
+ if(_payload) {
7
+
8
+ let { jwt, ...payload } = _payload
7
9
 
8
10
  if(!global.configs.jwt && !global.configs.jwt.secret) return log("ERROR: no jwt.secret defined in configs.")
9
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bee.js/node",
3
- "version": "0.0.32",
3
+ "version": "0.0.36",
4
4
  "description": "A JavaScript framework for making Node.js API´s",
5
5
  "main": "index.js",
6
6
  "scripts": {