q-koa 9.0.6 → 9.1.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 CHANGED
@@ -926,6 +926,24 @@ class APP {
926
926
  }
927
927
  }
928
928
 
929
+ if (fn === 'findAll') {
930
+ const disabledFindAllList = _.get(
931
+ app[appName],
932
+ 'appConfig.disabledFindAllList',
933
+ []
934
+ )
935
+ if (
936
+ disabledFindAllList.includes(controller) &&
937
+ !(
938
+ limit >= 0 ||
939
+ limit !== undefined ||
940
+ (where && !_.isEmpty(where))
941
+ )
942
+ ) {
943
+ throw new Error(`请使用条件`)
944
+ }
945
+ }
946
+
929
947
  let myInclude
930
948
  if (include) {
931
949
  if (relate) {
package/core/config.js CHANGED
@@ -131,6 +131,7 @@ module.exports = {
131
131
  excludes: ['admin'],
132
132
  },
133
133
  cacheModel: [],
134
+ disabledFindAllList: [],
134
135
  defaultRouter: (router) => (app) => {
135
136
  if (app.controller.cache) {
136
137
  router.get('/cache/get', app.controller.cache.get)
@@ -60,6 +60,15 @@ exports.loadModel = async ({ app, appName }) => {
60
60
  // const ori_target = modelList.find((m) => m.model === result[i])
61
61
  // const id = ori_target ? ori_target.id : null
62
62
  const id = i + 1
63
+
64
+ let countNumber = 0
65
+ if (app.model[result[i]]) {
66
+ countNumber = await app.model[result[i]].count()
67
+ }
68
+ if (countNumber >= 500) {
69
+ disabledFindAllList = [...disabledFindAllList, result[i]]
70
+ }
71
+
63
72
  const obj = {
64
73
  id,
65
74
  model: result[i],
@@ -211,6 +220,8 @@ exports.loadModel = async ({ app, appName }) => {
211
220
 
212
221
  await Promise.all([promise1, promise2])
213
222
  console.log('lodaModel success!')
223
+ console.warn(`disabledFindAllList: ${JSON.stringify(disabledFindAllList)}`)
224
+
214
225
  if (app.service.routes && app.model.routes) {
215
226
  await app.service.routes.initRouter({ app })
216
227
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "9.0.6",
3
+ "version": "9.1.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {