sql - 节点续集 - 选择空值
问题描述
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' }
解决方案
模型:诊断.js
...
status: {
type: DataTypes.STRING,
defaultValue: "enable", // <- default value will solve my problem
}
...
推荐阅读
- python - Azure 密钥保管库:合并证书
- git - 创建单独的功能分支并提交到 Git - 如何确保本地 git 存储库显示功能状态而不是原始/开发?
- xcode - 如何使用 CocoaPods 在 Xcode 中更新包中的依赖项?
- manim - 使用 manim 到轴上的点的距离
- javascript - 如何在 React 中停止 setInterval()
- react-native - 叮当声:警告:对“iPhoneSimulator”使用 sysroot,但针对“MacOSX”[-Wincompatible-sysroot]
- javascript - 如何使用数字角色注册指纹 javascript driver v3.0.0
- python - SSL 错误“协议已关闭”是什么意思?
- docker - 使用 -w 运行 docker 后,找不到通过 dockerfile 复制的脚本
- php - 如何在 Laravel Valet 中关闭 php 已弃用的警报?