Node.js 为什么要自动创建两个表?
使用sequelize.sync()部署表时。它创建了两个表(tagable,tagables)。我已经明确定义了表名。但要创建两个表。如果我将tableName设置为singular(tagable),它将只创建一个表Node.js 为什么要自动创建两个表?,node.js,sequelize.js,Node.js,Sequelize.js,使用sequelize.sync()部署表时。它创建了两个表(tagable,tagables)。我已经明确定义了表名。但要创建两个表。如果我将tableName设置为singular(tagable),它将只创建一个表 class Tagable extends Model {} Tagable.init({ id: { type: DataTypes.BIGINT.UNSIGNED, allowNull: false, autoInc
class Tagable extends Model {}
Tagable.init({
id: {
type: DataTypes.BIGINT.UNSIGNED,
allowNull: false,
autoIncrement: true,
primaryKey: true,
unique: true
},
tag_id: {
type: DataTypes.MEDIUMINT.UNSIGNED,
allowNull: false,
references: {
model: 'tags',
key: 'id'
}
},
tagable_id: {
type: DataTypes.BIGINT.UNSIGNED,
allowNull: false
},
tagable_type: {
type: DataTypes.TINYINT.UNSIGNED,
allowNull: false
}
}, {
sequelize,
modelName: 'Tagable',
tableName: 'tagables',
engine: 'MYISAM',
charset: 'utf8mb4',
collate: 'utf8mb4_unicode_ci',
timestamps: false
});