q-koa 10.8.4 → 10.8.6

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
@@ -340,7 +340,17 @@ class APP {
340
340
  let dirList = await fsPromise.readdir(
341
341
  path.resolve(__dirname, `${rootDirectory}/${APP_DIR}`)
342
342
  )
343
- dirList = dirList.filter((item) => this.config.includes.includes(item))
343
+ const includeList = this.config.includes.filter(Boolean).map((item) => {
344
+ if (typeof item === 'string') {
345
+ return {
346
+ app: item,
347
+ db: this.config.db.name || item,
348
+ }
349
+ } else {
350
+ return item
351
+ }
352
+ })
353
+ dirList = dirList.filter((item) => includeList.some((i) => i.app === item))
344
354
 
345
355
  let dbFlag = false
346
356
  for (let i = 0; i < dirList.length; i++) {
@@ -362,7 +372,9 @@ class APP {
362
372
  )
363
373
 
364
374
  try {
365
- const dbName = this.config.db.name || appName
375
+ const target = includeList.find((i) => i.app === appName)
376
+ const dbName =
377
+ (target ? target.db : '') || this.config.db.name || appName
366
378
  const db = connectDatabase(dbName)(this.config.db)
367
379
  if (!is_dev) {
368
380
  if (!dbFlag) {
package/core/config.js CHANGED
@@ -137,6 +137,7 @@ module.exports = {
137
137
  if (app.controller.cache) {
138
138
  router.get('/cache/get', app.controller.cache.get)
139
139
  router.get('/cache/clear', app.controller.cache.clear)
140
+ router.get('/cache/getAll', app.controller.cache.getAll)
140
141
  }
141
142
  if (app.model.weixin) {
142
143
  router.get('/weixin/h5_login', app.controller.weixin.h5_login)
@@ -1,5 +1,12 @@
1
1
  const { getAppByCtx, getUserByCtx, getConfig } = require('q-koa')
2
2
 
3
+ exports.getAll = async (ctx) => {
4
+ const { app, appName } = getAppByCtx(ctx)
5
+ const result = Object.keys(app.model).filter((model) => app.cache.get(model))
6
+ console.info(`cacheModel设置可CRUD同步更新`)
7
+ ctx.SUCCESS(result)
8
+ }
9
+
3
10
  exports.get = async (ctx) => {
4
11
  const { app, appName } = getAppByCtx(ctx)
5
12
  const key =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "10.8.4",
3
+ "version": "10.8.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {