node.js - 为什么sequelize会自动创建两个表?
问题描述
当我使用 sequelize.sync() 部署表时。它创建两个表( tagable , tagables )。我已经明确定义了表名。但续集创建两个表。如果我将 tableName 设置为单数(可标记),它只会创建 1 个表。
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
});
解决方案
推荐阅读
- python-3.x - Anaconda 没有加载 Tensorflow
- android - 安卓设备解锁时运行任务
- r - evir 库中的 shape() 函数错误
- python - 从数据框中的今天月份获取月份值 N-(x) 的函数
- javascript - 按字母顺序对表格行进行排序
- ssl - 即使我使用 SSL 配置了我的服务器,我是否需要将客户端证书发送到另一台服务器
- node.js - 使用 Mongoose 库更新 Express JS 中的 DB Shema
- javascript - 将设定值添加到预定义变量
- c++ - 这是什么意思移动操作永远不会被定义为删除的功能
- node.js - 多个 socket.io 服务器共享一个 HTTP/S 服务器