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.
|
|
|
const sequelize = require("./dbConnect")
|
|
|
|
const userModel = require("./model/userModel")
|
|
|
|
const expressModel = require("./model/expressModel")
|
|
|
|
const md5 = require("md5")
|
|
|
|
const {
|
|
|
|
getRandomExpressId
|
|
|
|
} = require("../utils/tools")
|
|
|
|
//将数据模型和表进行同步
|
|
|
|
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("用户数据初始化完毕")
|
|
|
|
}
|
|
|
|
|
|
|
|
const expressCount = await expressModel.count()
|
|
|
|
if (!expressCount) {
|
|
|
|
expressModel.bulkCreate([{
|
|
|
|
expressId: getRandomExpressId(),
|
|
|
|
senderCity: "深圳市",
|
|
|
|
senderName: "冰凉凉1",
|
|
|
|
receiverCity: "福州市",
|
|
|
|
receiverName: "叶丽丽",
|
|
|
|
isSigned: 1,
|
|
|
|
signedTime: "2024-10-24 11:58"
|
|
|
|
}, {
|
|
|
|
expressId: getRandomExpressId(),
|
|
|
|
senderCity: "深圳市",
|
|
|
|
senderName: "冰凉凉2",
|
|
|
|
receiverCity: "福州市",
|
|
|
|
receiverName: "叶丽丽",
|
|
|
|
isSigned: 1,
|
|
|
|
signedTime: "2024-10-24 11:58"
|
|
|
|
}, {
|
|
|
|
expressId: getRandomExpressId(),
|
|
|
|
senderCity: "深圳市",
|
|
|
|
senderName: "冰凉凉3",
|
|
|
|
receiverCity: "福州市",
|
|
|
|
receiverName: "叶丽丽",
|
|
|
|
isSigned: 1,
|
|
|
|
signedTime: "2024-10-24 11:58"
|
|
|
|
}])
|
|
|
|
console.log("express初始化完成")
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("数据库数据准备完成")
|
|
|
|
}
|
|
|
|
test()
|