zet-lib 1.0.90 → 1.0.91

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.
Files changed (2) hide show
  1. package/lib/connection.js +17 -13
  2. package/package.json +1 -1
package/lib/connection.js CHANGED
@@ -48,7 +48,7 @@ const orderByFn = (obj) => {
48
48
 
49
49
  const whereFn = (obj) => {
50
50
  const where = obj.where || {}
51
- //[{field:"your_field",option:"=>",value:"12",operator:"AND",isJSON : false, type:"text,json,date"}]
51
+ //[{field:"your_field",option:"=>",value:"12",operator:"AND",type:"text,json,date"}]
52
52
  const whereArray = obj.whereArray || []
53
53
  let increment = 1
54
54
  let arr = [],
@@ -81,19 +81,23 @@ const whereFn = (obj) => {
81
81
  if (item.isJSON) {
82
82
  wherequery += andOr + ` JSON_CONTAINS(${field}, '"${item.value}"' ,'$') ${operator}`
83
83
  } else {
84
- if (item.option.includes('{{value}}')) {
85
- item.option = item.option.replace('{{value}}', `$${increment}`)
86
- wherequery += `${andOr} ${field} ${item.option} ${operator}`
87
- } else if (item.option.includes('$')) {
88
- wherequery += `${andOr} ${field} ${item.option} ${operator}`
84
+ if (type == 'json') {
85
+ wherequery += andOr + ` JSON_CONTAINS(${field}, '"${item.value}"' ,'$') ${operator}`
89
86
  } else {
90
- wherequery += `${andOr} ${field} ${item.option} $${increment} ${operator}`
87
+ if (item.option.includes('{{value}}')) {
88
+ item.option = item.option.replace('{{value}}', `$${increment}`)
89
+ wherequery += `${andOr} ${field} ${item.option} ${operator}`
90
+ } else if (item.option.includes('$')) {
91
+ wherequery += `${andOr} ${field} ${item.option} ${operator}`
92
+ } else {
93
+ wherequery += `${andOr} ${field} ${item.option} $${increment} ${operator}`
94
+ }
95
+ let itemValue = item.value
96
+ if (item.option == '=') {
97
+ itemValue = Util.replaceAll(itemValue, '%', '')
98
+ }
99
+ arr.push(itemValue)
91
100
  }
92
- let itemValue = item.value
93
- if (item.option == '=') {
94
- itemValue = Util.replaceAll(itemValue, '%', '')
95
- }
96
- arr.push(itemValue)
97
101
  }
98
102
  increment++
99
103
  })
@@ -110,7 +114,7 @@ const whereFn = (obj) => {
110
114
  connection.results = async (obj) => {
111
115
  const select = obj.select || '*'
112
116
  const table = obj.table || ''
113
- //[{field:"your_field",option:"=>",value:"12",operator:"AND",isJSON : false}]
117
+ //[{field:"your_field",option:"=>",value:"12",operator:"AND",type:"text,json,date"}]
114
118
  const statement = obj.statement || ''
115
119
  const limit = obj.limit ? ` LIMIT ${obj.limit} ` : ''
116
120
  const offset = obj.hasOwnProperty('offset') ? ` OFFSET ${obj.offset} ` : obj.limit ? 'OFFSET 0' : ''
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "1.0.90",
3
+ "version": "1.0.91",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"