0

我有这部分代码我想同步它,但不能

this.sequelizeCon = new this.sequelize('mydb', 'root', '', {
  host: "127.0.0.1",
  port: 3306
})
var revision = this.sequelizeCon.define("revision",{
  version :{
    type:this.sequelize.INTEGER,
    primaryKey:true,
    allowNull:false
  }
})

revision.sync();

我得到了这个错误响应

[TypeError: Object [object Object] has no method 'apply']

谁能告诉我我的代码有什么问题..?

4

1 回答 1

0
var Sequelize = require('sequelize').Sequelize;

var dbConnector = function () {
    const DB_NAME = 'spring'
    const DB_USER = 'root'
    const DB_PASSWORD = ''

    var sequelize = new Sequelize(DB_NAME, DB_USER, DB_PASSWORD,
        {
            host: "127.0.0.1",
            port: 3306,
            dialect: 'mysql'
        }
    );
    var revision = sequelize.define("revision", {
        version: {
            type: Sequelize.INTEGER,
            primaryKey: true,
            allowNull: false
        }
    })
    revision.sync()
};

dbConnector()
"mysql2": "^2.2.5",
"sequelize": "^6.5.0",
于 2021-03-09T16:58:27.583 回答