如果使用了 Sequelize 的 Associations,这必须通过 sync() 生成表结构。...创建 model
创建模型,告诉 Sequelize 如何映射数据库表
const UserModel = sequelize.define('user', {
id: {
type: Sequelize.INTEGER...(11),
primaryKey: true, // 主键
autoIncrement: true, // 自动递增
},
username...,
primaryKey: true,
autoIncrement: true,
},
username: Sequelize.STRING(100),
})
const Student...autoIncrement: true,
},
username: Sequelize.STRING(100),
})
School.hasMany(Student, {as: 'student