You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
581 B
24 lines
581 B
3 days ago
|
const sequelize = require("./dbConnect")
|
||
|
const userModel = require("./model/userModel")
|
||
|
const md5 = require("md5")
|
||
|
//将数据模型和表进行同步
|
||
|
async function test() {
|
||
|
await sequelize.sync({
|
||
|
alter: true
|
||
|
})
|
||
|
|
||
|
//将需要数据的表初始化
|
||
|
const userCount = await userModel.count()
|
||
|
if (!userCount) {
|
||
|
//需要初始化
|
||
|
await userModel.create({
|
||
|
loginId: "test",
|
||
|
loginPwd: md5("123")
|
||
|
})
|
||
|
|
||
|
console.log("用户数据初始化完毕")
|
||
|
}
|
||
|
|
||
|
console.log("数据库数据准备完成")
|
||
|
}
|
||
|
test()
|