Sequelize Deprecated Error Message

前端 未结 3 1632
借酒劲吻你
借酒劲吻你 2021-02-04 08:27

I\'m very new to Node and I\'m getting my head around how ORM and Sequelize works. I\'ve been on the Sequelize website and copied the connection string and altered it to work wi

相关标签:
3条回答
  • 2021-02-04 09:08

    Updating to version:

    "sequelize": "^5.8.6"
    

    and removing operatorsAliases param from

    new Sequelize()
    

    removed depreciation warning

    0 讨论(0)
  • 2021-02-04 09:15
    const sequelize = new Sequelize({
      username: process.env.DBUSERNAME,
      host: process.env.DBHOST,
      database: process.env.DBNAME,
      password: process.env.DBPASSWORD,
      dialect: 'postgres',
      define: {
        timestamps: false,
      },
      operatorsAliases: false,
      pool: {
        max: 5,
        min: 0,
        idle: 10000
      },
    
    });
    
    0 讨论(0)
  • 2021-02-04 09:17

    These were the best explanations that I found for this deprecation warning:

    https://github.com/sequelize/sequelize/issues/8417

    http://docs.sequelizejs.com/manual/tutorial/querying.html#operators-aliases

    Adding "operatorsAliases: false" did override the warning message in my application.

    const Sequelize = require('sequelize')
    const sequelize = new Sequelize(
      DB_NAME,
      USERNAME, 
      PASSWORD,
      {
        host: HOSTNAME,
        dialect: 'mysql',
        logging: false,
        freezeTableName: true,
        operatorsAliases: false
      }
    )
    

    Note: as of sequelize@4.20.1 I started receiving "Invalid value" errors from Sequelize. I relented and used the following code to enable symbol operators:

    const Sequelize = require('sequelize')
    const Op = Sequelize.Op
    const sequelize = new Sequelize(
      DB_NAME,
      USERNAME, 
      PASSWORD,
      {
        host: HOSTNAME,
        dialect: 'mysql',
        logging: false,
        freezeTableName: true,
        operatorsAliases: {
          $and: Op.and,
          $or: Op.or,
          $eq: Op.eq,
          $gt: Op.gt,
          $lt: Op.lt,
          $lte: Op.lte,
          $like: Op.like
        }
      }
    )
    
    0 讨论(0)
提交回复
热议问题