q-koa 11.8.6 → 11.8.7

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/core/app.js CHANGED
@@ -1099,7 +1099,6 @@ class APP {
1099
1099
  $in: [Sequelize.literal(item.$in)],
1100
1100
  }
1101
1101
  }
1102
- console.log(item.$lt)
1103
1102
  if (
1104
1103
  item.hasOwnProperty('$lt') &&
1105
1104
  typeof item.$lt === 'string'
@@ -198,11 +198,61 @@ exports.initData = async ({ includes, excludes, app, ctx }) => {
198
198
  }
199
199
  })
200
200
  } else {
201
+ const formatData =
202
+ fn === 'findAll' &&
203
+ data &&
204
+ lodash.isObject(data) &&
205
+ data.hasOwnProperty('where')
206
+ ? Object.keys(data).reduce((a, b) => {
207
+ return {
208
+ ...a,
209
+ ...(b === 'where'
210
+ ? {
211
+ [b]: Object.keys(data[b]).reduce((_a, _b) => {
212
+ return {
213
+ ..._a,
214
+ ...(['$gt', '$lt'].some((i) =>
215
+ data[b][_b].hasOwnProperty(i)
216
+ )
217
+ ? {
218
+ [_b]: data[b][_b],
219
+ ...(typeof data[b][_b].$gt ===
220
+ 'string' &&
221
+ data[b][_b].hasOwnProperty('$gt')
222
+ ? {
223
+ [_b]: {
224
+ $gt: Sequelize.literal(
225
+ data[b][_b].$gt
226
+ ),
227
+ },
228
+ }
229
+ : {}),
230
+ ...(typeof data[b][_b].$lt ===
231
+ 'string' &&
232
+ data[b][_b].hasOwnProperty('$lt')
233
+ ? {
234
+ [_b]: {
235
+ $lt: Sequelize.literal(
236
+ data[b][_b].$lt
237
+ ),
238
+ },
239
+ }
240
+ : {}),
241
+ }
242
+ : { [_b]: data[b][_b] }),
243
+ }
244
+ }, {}),
245
+ }
246
+ : { [b]: data[b] }),
247
+ }
248
+ }, {})
249
+ : data
250
+ // console.log('formatData', data, '-->', formatData)
201
251
  return app.model[model][fn]({
202
252
  order,
203
253
  limit,
204
254
  include: myInclude,
205
- ...data,
255
+ ...formatData,
206
256
  }).then((result) => {
207
257
  const list =
208
258
  data && data.omit && Array.isArray(data.omit)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "11.8.6",
3
+ "version": "11.8.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {