q-koa 11.3.1 → 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.
|
@@ -126,6 +126,13 @@ exports.initList = {
|
|
|
126
126
|
defaultValue: [],
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
exports.initTableList = {
|
|
130
|
+
type: Sequelize.JSON,
|
|
131
|
+
comment: '初始化table',
|
|
132
|
+
allowNull: false,
|
|
133
|
+
defaultValue: [],
|
|
134
|
+
}
|
|
135
|
+
|
|
129
136
|
exports.autoData = {
|
|
130
137
|
type: Sequelize.JSON,
|
|
131
138
|
comment: 'initData过滤数据',
|
|
@@ -89,6 +89,7 @@ exports.loadModel = async ({ app, appName }) => {
|
|
|
89
89
|
select: config.select,
|
|
90
90
|
excludes: config.excludes,
|
|
91
91
|
initList: config.initList,
|
|
92
|
+
initTableList: config.initTableList,
|
|
92
93
|
defaultOrder: config.defaultOrder,
|
|
93
94
|
excludeAuth: config.excludeAuth,
|
|
94
95
|
comment: config.comment,
|
|
@@ -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) => {
|
|
@@ -175,6 +180,8 @@ exports.showTables = async (ctx) => {
|
|
|
175
180
|
autoData: lodash.get(target, 'autoData', null),
|
|
176
181
|
// 有些model需要前置查询其它model数据
|
|
177
182
|
initList: lodash.get(target, 'initList', []),
|
|
183
|
+
// 有些model的table需要前置查询模型
|
|
184
|
+
initTableList: lodash.get(target, 'initTableList', []),
|
|
178
185
|
// 局部更新列表
|
|
179
186
|
editInline: lodash.get(target, 'editInline', {}),
|
|
180
187
|
// 有些model需要前置查询其它model数据
|