q-koa 11.5.6 → 11.6.0
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 +20 -5
- package/package.json +1 -1
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
|
|
1130
|
-
(
|
|
1131
|
-
(item
|
|
1132
|
-
|
|
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
|
]({
|