q-koa 11.3.2 → 11.3.3
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.
|
@@ -21,20 +21,25 @@ exports.initModel = async (ctx) => {
|
|
|
21
21
|
: {
|
|
22
22
|
alter: true,
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
if (Array.isArray(model)) {
|
|
26
|
+
await Promise.all(model.map((m) => app.model[m].sync(config)))
|
|
27
|
+
return ctx.SUCCESS('ok')
|
|
28
|
+
}
|
|
24
29
|
if (model === 'all') {
|
|
25
30
|
const modelList = Object.keys(app.model)
|
|
26
31
|
await Promise.all(modelList.map((m) => app.model[m].sync(config)))
|
|
27
32
|
return ctx.SUCCESS('ok')
|
|
28
33
|
}
|
|
29
34
|
if (app.model[model]) {
|
|
30
|
-
if (Object.keys(app.model[model]).length === 0)
|
|
35
|
+
if (Object.keys(app.model[model]).length === 0) {
|
|
31
36
|
return ctx.ERROR('请检查,model为空')
|
|
37
|
+
}
|
|
32
38
|
const result = await app.model[model].sync(config)
|
|
33
39
|
return ctx.SUCCESS(result)
|
|
34
40
|
} else {
|
|
35
41
|
return ctx.ERROR(`app.model没有${model}`)
|
|
36
42
|
}
|
|
37
|
-
return ctx.SUCCESS(null)
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
exports.customRouter = async (ctx) => {
|