我在MySql中有一个数据库,我想在运行节点server.js时使用sequelize制作3个表
现在运行它时,服务器仅执行代码中的最后一个表:
执行(默认):如果表不存在main_events,则创建表(id为INTEGER NOT NULL auto_increment,event_name VARCHAR(255),event_date DATETIME,event_time TIME,createdDATETIME NOT NULL,updateAt DATETIME NOT NULL,主键(id))ENGINE = InnoDB;执行(默认):SHOW INDEX FROM main_events FROM project2_db该应用程序正在侦听:http // localhost:8080
有什么想法为什么注册表和来宾表不执行?
var list = sequelize.define("registry", {
//Item column set to only accept alphanumeric
item: {
type: Sequelize.STRING,
validate: {
isAlphanumeric: true,
}
},
//Quantity column set to only accept alphanumeric
quantity: {
type: Sequelize.INTEGER,
validate: {
isAlphanumeric: true,
}
},
});
return list;
};
//Setup for "guest" table
module.exports = function (sequelize, Sequelize) {
var guests = sequelize.define("guest", {
//Guest name column set to only accept letters
guest_name: {
type: Sequelize.STRING,
validate: {
isAlpha: true,
}
},
//Email column set to only accept email format (test@gmail.com)
email: {
type: Sequelize.STRING,
validate: {
isEmail: true,
}
},
//Phone number column set to only accept 10 numbers
phone_number: {
type: Sequelize.STRING,
validate: {
isNumeric: true,
max: 10,
min: 10,
}
},
});
return guests;
};
//Setup for "main_event" table
module.exports = function (sequelize, Sequelize) {
var events = sequelize.define("main_event", {
//Event name column set to only accept alphanumeric
event_name: {
type: Sequelize.STRING,
validate: {
isAlphanumeric: true,
}
},
//Event date column
//********THIS MIGHT CHANGE DEPENDING ON THE FORMAT*********
event_date: {
type: Sequelize.DATE,
},
//Phone number column set to only accept 10 numbers
//********THIS MIGHT CHANGE DEPENDING ON THE FORMAT*********
event_time: {
type: Sequelize.TIME,
},
});
return events;
};