node.js - 如何使用 Sequelize 查询 WHERE "NOT NULL"AND "NOT EQUAL TO [STRING]"?

标签 node.js sequelize.js

我需要获取属性“type1”、“type2”等“不等于‘null’”和“不等于字符串‘no_issue’”的数据。我尝试了几种不同的方法但没有运气,这就是我目前无法使用的方法:

  [Op.and]: [
        { type1: { [Op.not]: null }},
        { type1: { [Op.ne]: 'no_issue' }},
        { next_item: 'next' }
     ],
     [Op.and]: [
      { type2: { [Op.not]: null }},
      { type2: { [Op.ne]: 'no_issue' }},
      { next_item: 'next' }
   ],
      [Op.and]: [
        { type3: { [Op.not]: null }},
        { type3: { [Op.ne]: 'no_issue' }},
        { next_item: 'next' }
    ],
    [Op.and]: [
      { type4: { [Op.not]: null }},
      { type4: { [Op.ne]: 'no_issue' }},
      { next_item: 'next' }
    ],
    [Op.and]: [
      { type5: { [Op.not]: null }},
      { type5: { [Op.ne]: 'no_issue' }},
      { next_item: 'next' }
    ]
    }
这看起来是正确的,但我显然错过了一些东西。提前致谢!

最佳答案

Op.and 应该是一个对象数组

      [Op.and]: [
         { type1: { [Op.not]: null }},
         { type1: { [Op.ne]: 'no_issue' }}
      ],...

关于node.js - 如何使用 Sequelize 查询 WHERE "NOT NULL"AND "NOT EQUAL TO [STRING]"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67909955/

相关文章:

javascript - Node.js 流 'end' 事件未触发

javascript - 我将如何为使用标准输出的东西编写测试?

node.js - 使用 OR 条件序列化 FindOrCreate 函数

sequelize.js - Sequelize : Change DB password on prduction DB

node.js - sequelize 无法将对象数组保存到表中

node.js - ExpressJS 在请求函数中提供静态文件

javascript - 序列化年份和月份

mysql - 获取层次结构数据nodejs-sequelizejs-mysql

node.js - 使用 Sequelize 查询自连接,包括相关记录

javascript - Import.meta.env 在生产构建 vitejs 上未定义