sequelizejs(nodejs orm)无法同步模型

时间:2012-12-17 08:42:05

标签: node.js sequelize.js

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

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']

任何人都可以告诉我我的代码有什么问题吗??

1 个答案:

答案 0 :(得分:0)

MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your@gmail.com
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls
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()