Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 为什么要自动创建两个表?_Node.js_Sequelize.js - Fatal编程技术网

Node.js 为什么要自动创建两个表?

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

使用sequelize.sync()部署表时。它创建了两个表(tagable,tagables)。我已经明确定义了表名。但要创建两个表。如果我将tableName设置为singular(tagable),它将只创建一个表

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 
});