@bee.js/node 0.0.33 → 0.0.37

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
@@ -3,9 +3,9 @@ const log = require('../beeHive/log')
3
3
 
4
4
  module.exports = function token(_payload = null, header = {}) {
5
5
 
6
- let { jwt, ...payload } = _payload
6
+ if(_payload) {
7
7
 
8
- if(payload) {
8
+ let { jwt, ...payload } = _payload
9
9
 
10
10
  if(!global.configs.jwt && !global.configs.jwt.secret) return log("ERROR: no jwt.secret defined in configs.")
11
11
 
@@ -34,11 +34,15 @@ module.exports = function token(_payload = null, header = {}) {
34
34
  .update(`${header}.${payload}`)
35
35
  .digest("base64")
36
36
 
37
- this.data.jwt = this.data.jwt ? [this.data.jwt] : this.data.jwt
37
+ let token = `${header}.${payload}.${signature}`
38
+
39
+ this.data.jwt = this.data.jwt && typeof this.data.jwt !== "object"
40
+ ? [this.data.jwt]
41
+ : this.data.jwt
38
42
 
39
43
  this.data.jwt = !this.data.jwt
40
- ? `${header}.${payload}.${signature}`
41
- : this.data.jwt.concat(`${header}.${payload}.${signature}`)
44
+ ? token
45
+ : this.data.jwt.concat(token)
42
46
 
43
47
  this.counters.jwt = (this.counters.jwt||0) + 1
44
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bee.js/node",
3
- "version": "0.0.33",
3
+ "version": "0.0.37",
4
4
  "description": "A JavaScript framework for making Node.js API´s",
5
5
  "main": "index.js",
6
6
  "scripts": {