首页 > 解决方案 > 节点续集 - 选择空值

问题描述

var where = {
  [Op.or]:
      [
          { status: { [Op.ne]: 'disable' } },
          { status: { [Op.eq]: null } }
      ],
}

db.diagnostic.findAll({ where: where }).then(resp => {
  res.send(resp)
})

上面的代码正在运行
,但是,

var where = {
  status: { [Op.ne]: 'disable' } // I want use only this code instead of `or`
}

db.diagnostic.findAll({ where: where }).then(resp => {
  res.send(resp)
})

我只想使用status: { [Op.ne]: 'disable' }

标签: sqlnode.jssequelize.jswhere-clause

解决方案


模型:诊断.js

...
    status: {
      type: DataTypes.STRING,
      defaultValue: "enable", // <-  default value will solve my problem
    }
...

推荐阅读