q-koa 13.2.4 → 13.2.5

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.
@@ -67,6 +67,28 @@ const compareIndex = (tableIndexList, modelIndexList = [], model) => {
67
67
  return { isSame: flag, remote, current }
68
68
  }
69
69
 
70
+ exports.countAndMaxId = async (ctx, _data) => {
71
+ const { app, appName } = getAppByCtx(ctx)
72
+ const { model } = ctx.request.body
73
+ if (!model) {
74
+ ctx.SUCCESS(null)
75
+ return null
76
+ }
77
+ const count = await app.model[model].count()
78
+ const result = await app.model[model].findOne({
79
+ attributes: ['id'],
80
+ order: [['id', 'DESC']],
81
+ })
82
+
83
+ const payLoad = {
84
+ count,
85
+ max_id: result ? result.id : 0,
86
+ }
87
+
88
+ ctx.SUCCESS(payLoad)
89
+ return payLoad
90
+ }
91
+
70
92
  exports.initModel = async (ctx) => {
71
93
  const { app, appName } = getAppByCtx(ctx)
72
94
  const { model, option } = ctx.request.body
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "13.2.4",
3
+ "version": "13.2.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {