q-koa 11.5.6 → 11.6.2

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
@@ -947,6 +947,7 @@ class APP {
947
947
  is_split = false,
948
948
  autoInclude = true,
949
949
  omit = [],
950
+ includeWhere = {},
950
951
  ...other
951
952
  } = ctx.request.body
952
953
  if (['findOne', 'findAll', 'findAndCountAll'].includes(fn)) {
@@ -1126,11 +1127,25 @@ class APP {
1126
1127
  // 拆分
1127
1128
  if (is_split) {
1128
1129
  if (fn === 'findAndCountAll') {
1129
- const requiredInclude = myInclude.filter(
1130
- (item) =>
1131
- (item.where && !item.hasOwnProperty('required')) ||
1132
- (item.hasOwnProperty('required') && item.required)
1133
- )
1130
+ const requiredInclude = myInclude
1131
+ .filter(
1132
+ (item) =>
1133
+ (item.where && !item.hasOwnProperty('required')) ||
1134
+ (item.hasOwnProperty('required') && item.required)
1135
+ )
1136
+ .map((item) => {
1137
+ return {
1138
+ ...item,
1139
+ where: {
1140
+ ...item.where,
1141
+ ...(includeWhere[item.model.getName()]
1142
+ ? {
1143
+ ...includeWhere[item.model.getName()],
1144
+ }
1145
+ : {}),
1146
+ },
1147
+ }
1148
+ })
1134
1149
  const { count, rows } = await app[appName].model[controller][
1135
1150
  fn
1136
1151
  ]({
@@ -52,6 +52,6 @@ exports.login = async (ctx) => {
52
52
  token,
53
53
  user: app.appConfig.loginData
54
54
  ? lodash.omit(result.toJSON(), app.appConfig.loginData.omit)
55
- : result,
55
+ : result.toJSON(),
56
56
  })
57
57
  }
@@ -47,7 +47,7 @@ exports.login = async (ctx) => {
47
47
  token,
48
48
  user: app.appConfig.loginData
49
49
  ? lodash.omit(result.toJSON(), app.appConfig.loginData.omit)
50
- : result,
50
+ : result.toJSON(),
51
51
  })
52
52
  }
53
53
  if (
@@ -212,7 +212,7 @@ exports.login = async (ctx) => {
212
212
  token,
213
213
  user: app.appConfig.loginData
214
214
  ? lodash.omit(result.toJSON(), app.appConfig.loginData.omit)
215
- : result,
215
+ : result.toJSON(),
216
216
  })
217
217
  }
218
218
 
@@ -432,7 +432,7 @@ exports.checkLogin = async (ctx) => {
432
432
  token,
433
433
  user: app.appConfig.loginData
434
434
  ? lodash.omit(result.toJSON(), app.appConfig.loginData.omit)
435
- : result,
435
+ : result.toJSON(),
436
436
  })
437
437
  }
438
438
 
@@ -498,7 +498,7 @@ exports.mp_login = async (ctx) => {
498
498
  token,
499
499
  user: app.appConfig.loginData
500
500
  ? lodash.omit(result.toJSON(), app.appConfig.loginData.omit)
501
- : result,
501
+ : result.toJSON(),
502
502
  })
503
503
  }
504
504
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "11.5.6",
3
+ "version": "11.6.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {