q-koa 11.7.0 → 11.8.1
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
|
@@ -618,6 +618,11 @@ class APP {
|
|
|
618
618
|
...this.app[appName].attributes,
|
|
619
619
|
[folder]: _attributes,
|
|
620
620
|
}
|
|
621
|
+
const indexes = _.get(
|
|
622
|
+
this.app[appName].config[folder],
|
|
623
|
+
'indexList',
|
|
624
|
+
[]
|
|
625
|
+
)
|
|
621
626
|
|
|
622
627
|
const instance = this.app[appName].sequelize.define(
|
|
623
628
|
folder,
|
|
@@ -643,6 +648,11 @@ class APP {
|
|
|
643
648
|
}
|
|
644
649
|
},
|
|
645
650
|
},
|
|
651
|
+
...(indexes.length > 0
|
|
652
|
+
? {
|
|
653
|
+
indexes,
|
|
654
|
+
}
|
|
655
|
+
: {}),
|
|
646
656
|
}
|
|
647
657
|
)
|
|
648
658
|
instance.getName = function () {
|
|
@@ -797,13 +807,9 @@ class APP {
|
|
|
797
807
|
Array.isArray(
|
|
798
808
|
this.app[appName].attributes[model][model1 + '_id'].defaultValue
|
|
799
809
|
)) ||
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
(this.app[appName].attributes[model][model1 + '_id'].type &&
|
|
804
|
-
this.app[appName].attributes[model][model1 + '_id'].type.key &&
|
|
805
|
-
this.app[appName].attributes[model][model1 + '_id'].type.key ===
|
|
806
|
-
'JSON')
|
|
810
|
+
this.app[appName].attributes[model][model1 + '_id'].type ===
|
|
811
|
+
Sequelize.DataTypes.JSON
|
|
812
|
+
|
|
807
813
|
if (!is_multiple) {
|
|
808
814
|
this.app[appName].model[model].hasOne(
|
|
809
815
|
this.app[appName].model[model1],
|
|
@@ -1385,13 +1391,7 @@ class APP {
|
|
|
1385
1391
|
(app[appName].attributes[controller][modelName + '_id']
|
|
1386
1392
|
.type &&
|
|
1387
1393
|
app[appName].attributes[controller][modelName + '_id']
|
|
1388
|
-
.type ===
|
|
1389
|
-
(app[appName].attributes[controller][modelName + '_id']
|
|
1390
|
-
.type &&
|
|
1391
|
-
app[appName].attributes[controller][modelName + '_id']
|
|
1392
|
-
.type.key &&
|
|
1393
|
-
app[appName].attributes[controller][modelName + '_id']
|
|
1394
|
-
.type.key === 'JSON')
|
|
1394
|
+
.type === Sequelize.DataTypes.JSON)
|
|
1395
1395
|
)
|
|
1396
1396
|
if (is_single) {
|
|
1397
1397
|
rows[i].setDataValue(
|
|
@@ -1544,13 +1544,7 @@ class APP {
|
|
|
1544
1544
|
(app[appName].attributes[controller][modelName + '_id']
|
|
1545
1545
|
.type &&
|
|
1546
1546
|
app[appName].attributes[controller][modelName + '_id']
|
|
1547
|
-
.type ===
|
|
1548
|
-
(app[appName].attributes[controller][modelName + '_id']
|
|
1549
|
-
.type &&
|
|
1550
|
-
app[appName].attributes[controller][modelName + '_id']
|
|
1551
|
-
.type.key &&
|
|
1552
|
-
app[appName].attributes[controller][modelName + '_id']
|
|
1553
|
-
.type.key === 'JSON')
|
|
1547
|
+
.type === Sequelize.DataTypes.JSON)
|
|
1554
1548
|
)
|
|
1555
1549
|
|
|
1556
1550
|
if (is_single) {
|
|
@@ -1620,14 +1614,7 @@ class APP {
|
|
|
1620
1614
|
app[appName].attributes[controller][modelName + '_id']
|
|
1621
1615
|
.type &&
|
|
1622
1616
|
app[appName].attributes[controller][modelName + '_id']
|
|
1623
|
-
.type ===
|
|
1624
|
-
(app[appName].attributes[controller][modelName + '_id'] &&
|
|
1625
|
-
app[appName].attributes[controller][modelName + '_id']
|
|
1626
|
-
.type &&
|
|
1627
|
-
app[appName].attributes[controller][modelName + '_id'].type
|
|
1628
|
-
.key &&
|
|
1629
|
-
app[appName].attributes[controller][modelName + '_id'].type
|
|
1630
|
-
.key === 'JSON')
|
|
1617
|
+
.type === Sequelize.DataTypes.JSON)
|
|
1631
1618
|
)
|
|
1632
1619
|
|
|
1633
1620
|
if (is_single) {
|
|
@@ -203,6 +203,13 @@ exports.bulkCreateList = {
|
|
|
203
203
|
defaultValue: [],
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
exports.indexList = {
|
|
207
|
+
type: Sequelize.JSON,
|
|
208
|
+
comment: '索引',
|
|
209
|
+
allowNull: false,
|
|
210
|
+
defaultValue: [],
|
|
211
|
+
}
|
|
212
|
+
|
|
206
213
|
exports.alias = {
|
|
207
214
|
type: Sequelize.VIRTUAL,
|
|
208
215
|
comment: 'alias',
|
|
@@ -107,6 +107,7 @@ exports.loadModel = async ({ app, appName }) => {
|
|
|
107
107
|
editInline: config.editInline,
|
|
108
108
|
deleteCheckList: config.deleteCheckList,
|
|
109
109
|
bulkCreateList: config.bulkCreateList,
|
|
110
|
+
indexList: config.indexList,
|
|
110
111
|
list: attributes.map((attr, index) => {
|
|
111
112
|
const name = attr.match(/exports.(.*)=/)[1].trim()
|
|
112
113
|
let defaultValue = ''
|
|
@@ -231,6 +231,8 @@ exports.showTables = async (ctx) => {
|
|
|
231
231
|
deleteCheckList: lodash.get(target, 'deleteCheckList', []),
|
|
232
232
|
// 批量更新字段
|
|
233
233
|
bulkCreateList: lodash.get(target, 'bulkCreateList', []),
|
|
234
|
+
// 索引
|
|
235
|
+
indexList: lodash.get(target, 'indexList', []),
|
|
234
236
|
|
|
235
237
|
fn: app.controller[_model] ? Object.keys(app.controller[_model]) : [],
|
|
236
238
|
}
|