Commit 1825e86e by lixinming

no message

parent 4236aaf6
......@@ -15,7 +15,7 @@ export const TablesConfig = [
},
branchName: {type:Sequelize.STRING(100), allowNull:false}, //支部名称
},
association: [{}]
association: []
},
{
tableNameCn:'后台用户表',
......@@ -32,7 +32,7 @@ export const TablesConfig = [
token:{type:Sequelize.STRING(100), allowNull:false},
tokenMs:{type:Sequelize.DATE, allowNull:false}
},
association: [{}]
association: []
},
{
tableNameCn:'行政职务表',
......@@ -47,7 +47,7 @@ export const TablesConfig = [
},
administrativePositionName: {type:Sequelize.STRING(100), allowNull:false}
},
association: [{}]
association: []
},
{
tableNameCn:'党内职务表',
......@@ -62,7 +62,7 @@ export const TablesConfig = [
},
partyPositionsName: {type:Sequelize.STRING(100), allowNull:false}
},
association: [{}]
association: []
},
{
tableNameCn:'所属科室表',
......@@ -77,7 +77,7 @@ export const TablesConfig = [
},
departmentName: {type:Sequelize.STRING(100), allowNull:false}
},
association: [{}]
association: []
},
{
tableNameCn:'课程类型',
......@@ -92,7 +92,7 @@ export const TablesConfig = [
},
courseTypeName: {type:Sequelize.STRING(100), allowNull:false}
},
association: [{}]
association: []
},
{
tableNameCn:'党员基础信息表',
......
......@@ -9,18 +9,24 @@ let baseDB = {};
export async function initMysqlModel() {
/**初始化表 */
for (let i =0; i < TablesConfig.length; i++) {
let { tableName, schema, association, tableNameCn } = TablesConfig[i];
let { tableName, schema } = TablesConfig[i];
let schemaConf = {
freezeTableName:true, //true表示使用给定的表名,false表示模型名后加s作为表名
timestamps:false //true表示给模型加上时间戳属性(createAt、updateAt),false表示不带时间戳属性
};
let model = mysqlDB.define( tableName, schema, schemaConf);
let model = mysqlDB.define( tableName, schema, schemaConf);
baseDB[tableName] = model.sync({}).then();
baseDB[tableName] = await model.sync({}).then();
}
/**初始化表关联 */
for (let i =0; i < TablesConfig.length; i++) {
let { tableName, association } = TablesConfig[i];
association.forEach( (item:any) => {
if (item) {
let {type, check} = item;
......@@ -32,9 +38,6 @@ export async function initMysqlModel() {
baseDB[tableName].belongsTo(baseDB[check]);
}
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment