当前位置:网站首页>Query for Boolean field as "not true" (e.g. either false or non-existent)
Query for Boolean field as "not true" (e.g. either false or non-existent)
2022-07-05 00:49:00 【Superior virtue and weak water】
problem :
I'm sure I'm missing something very basic in MongoDB queries, can't seem to get this simple condition. I'm sure I'm MongoDB Some very basic things are missing from the query , It seems impossible to obtain such a simple condition .
Consider this collection Consider this set
> db.tests.find(){ "_id" : ObjectId("..."), "name" : "Test1" , "deleted" : true}{ "_id" : ObjectId("..."), "name" : "Test2" , "deleted" : false}{ "_id" : ObjectId("..."), "name" : "Test3" }I would simply like to query all the items that are "not deleted" I just want to check all “ Not delete ” Project
I know how to find the item that has a "deleted" flag set to true: I know how to find “ deleted ” Flag set to true Project :
> db.tests.find({deleted:true}){ "_id" : ObjectId("..."), "name" : "Test1" , "deleted" : true}But how do I find all items that are NOT "deleted" (eg negate the above query, or in other words, any items that either doesn't have a "deleted" field, or have it with value false But how did I find out , Are all the projects "deleted" ( For example, deny the above query , Or to put it another way , Without any items "deleted" field , Or value has it false
What I tried by guessing (please don't laugh...) What do I guess ( Please don't laugh ......)
> db.tests.find({$not : {deleted: true}})(returns no results)( No results returned )
> db.tests.find({$not : {$eq:{deleted:true}}})error: { "$err" : "invalid operator: $eq", "code" : 10068 } error :{“$ err”:“ Invalid operator :$ eq”,“code”:10068}
> db.tests.find({deleted:{$not: true}})error: { "$err" : "invalid use of $not", "code" : 13041 } error :{“$ err”:“ Invalid use $ not”,“ Code ”:13041}
> db.tests.find({deleted:{$not: {$eq:true}}})error: { "$err" : "invalid use of $not", "code" : 13034 } error :{“$ err”:“ Invalid use $ not”,“ Code ”:13034}
What am I missing? What I missed ?
Solution :
Reference resources : https://stackoom.com/en/question/1H2UQ边栏推荐
- 挖财学院开户安全的吗?开户怎么开?
- P3304 [sdoi2013] diameter (diameter of tree)
- TS quick start - functions
- SAP UI5 应用开发教程之一百零七 - SAP UI5 OverflowToolbar 容器控件介绍的试读版
- Life is changeable, and the large intestine covers the small intestine. This time, I can really go home to see my daughter-in-law...
- Nine Qi single chip microcomputer ny8b062d single key control four LED States
- 程序员SQL数据脚本编码能力弱,BI做不出来怎么办?
- Five papers recommended for the new development of convolutional neural network in deep learning
- [Yocto RM]10 - Images
- Parsing of XML
猜你喜欢
![[paper reading] cavemix: a simple data augmentation method for brain vision segmentation](/img/41/eb790e7419a158e985fa503bd7dc17.png)
[paper reading] cavemix: a simple data augmentation method for brain vision segmentation

skimage: imread & imsave & imshow
![[STM32] (I) overview and GPIO introduction](/img/6e/421238a892b557721e85c919a4eeb1.jpg)
[STM32] (I) overview and GPIO introduction

揭露测试外包公司,关于外包,你或许听到过这样的声音

4. Scala writes HelloWorld in idea, in-depth analysis of accompanying objects, and association of source packages

College degree, what about 33 year old Baoma? I still sell and test, and my monthly income is 13K+

Visual explanation of Newton iteration method

Fs8b711s14 electric wine bottle opener MCU IC scheme development special integrated IC

pycharm专业版下载安装教程

Ap8022 switching power supply small household appliances ACDC chip offline switching power supply IC
随机推荐
What if the programmer's SQL data script coding ability is weak and Bi can't do it?
Distributed base theory
SAP UI5 应用开发教程之一百零七 - SAP UI5 OverflowToolbar 容器控件介绍的试读版
The waterfall flow layout demo2 (method 2) used by the uniapp wechat applet (copy and paste can be used without other processing)
分布式BASE理论
lambda表达式
[paper reading] Tun det: a novel network for meridian ultra sound nodule detection
pycharm专业版下载安装教程
URLs and URIs
Hisilicon 3559 universal platform construction: YUV422 pit stepping record
The most complete regular practical guide of the whole network. You're welcome to take it away
Kibana index, mapping, document operation
Hologres query management and timeout processing
"Upside down salary", "equal replacement of graduates" these phenomena show that the testing industry has
程序员SQL数据脚本编码能力弱,BI做不出来怎么办?
uniapp上传头像
P4281 [ahoi2008] emergency assembly / gathering (LCA)
2022.07.03(LC_6111_统计放置房子的方式数)
[STM32] (I) overview and GPIO introduction
Summer challenge brings you to play harmoniyos multi terminal piano performance