mongodb - 如何搜索不等于指定值的值?
问题描述
我正在使用 MongoDB,我需要一个查询来检查一个值不是某个值,我知道如何搜索这样的值:
db.getCollection('ships').find({"name": "MY BOAT"})
所以假设我需要一个查询来查找名称不是“MY BOAT”的条目
我已经检查了$NOT
运算符https://docs.mongodb.com/manual/reference/operator/query/not/
但不明白如何应用它。
解决方案
db.getCollection('ships').find( { name: { $ne: "MY BOAT" } } )
https://docs.mongodb.com/manual/reference/operator/query/ne/
follow the above url for more information
推荐阅读
- elasticsearch - 什么时候在 Lucene 中应用删除
- python - 允许用户管理电子邮件的频率?- Python 批量邮件程序
- python - 模块“时间”没有属性“时钟”
- r - R循环遍历子文件夹
- python - 即使满足条件,如果语句未评估为 True
- node.js - 如何即时获取模型参考nestjs mongoose
- angular - 无法加载 npm\ng,因为在此系统上禁用了运行脚本
- typescript - “{}”类型的参数不可分配给“配置”类型的参数
'。本阿瓦德教程 - django - 有没有办法在没有 oauth2 的情况下验证 google play 购买?
- c# - C# 对具有给定值的文本框进行排序/排序