当前位置:网站首页>Conditional grouping with $exists inside $cond
Conditional grouping with $exists inside $cond
2022-06-25 07:11:00 【French red wine sweet】
problem :
I have two keys A and B and their existence in the document is mutually exclusive. I have two keys A and B, Their existence in the document is mutually exclusive .I have to group by A when A exists and group by B when B exists. When A I must press... When I exist A grouping , When B I must press... When I exist B grouping .So I am $project ing the required value into a computed key called MyKey on which I'll perform a $group . So I $project Put the required values into a file named MyKey In the calculation key of , I will execute... On this key $group .But it looks like I'm making a mistake with the syntax. But it seems that I made a mistake in grammar .I tried writing $project in two ways: I try to write in two ways $project :
{$project: {MyKey: {$cond: [{$exists: ["$A", true]}, "$A", "$B"]}}}
and and
{$project: {MyKey: {$cond: [{"A": {$exists:true}}, "$A", "$B"]}}}
But I keep getting the error: But I keep getting error messages :
{ "errmsg" : "exception: invalid operator '$exists'", "code" : 15999, "ok" : 0 } ...
What's going wrong? What's up? ?
Solution :
Reference resources : https://stackoom.com/en/question/xdcC边栏推荐
- Cloning and importing DOM nodes
- ES 终于可以搜到”悟空哥“了!
- Baidu map - introductory tutorial
- Usage of STL map
- Change the current count of auto increment values in MySQL- Changing the current count of an Auto Increment value in MySQL?
- Report on development status and investment strategy recommendations of global and Chinese graphite polystyrene board industry 2022-2028
- Are you still doing the dishes yourself? Teach you how to make dishwasher controller with single chip microcomputer
- Derivation of sin (a+b) =sina*cosb+sinb*cosa
- Learn the first routine of FPGA
- Acwing / 2004. Mauvaise écriture
猜你喜欢

Three laws of go reflection

【xxl-job】池塘水绿风微暖,记得玉真初见面

【工具分享】一款颜值与技能并重的软件

高效探索|ES地理位置查询的一次应用实践

Understand ZBrush carving software and game modeling analysis

Esp8266 & sg90 steering gear & Lighting Technology & Arduino

Message queue table structure for storing message data

分布式锁中的王者方案 - Redisson
![[轻松学会shell编程]-5、计划任务](/img/6f/8067d4201f0c2e7a692d89885e3ad9.png)
[轻松学会shell编程]-5、计划任务

使用OpenGL绘制shp文件
随机推荐
keil debug查看变量提示not in scope
lotus v1.16.0-rc2 Calibration-net
48 张图 | 手摸手教你微服务的性能监控、压测和调优
Lotus v1.16.0-rc2 Calibration net
Direct select sort and quick sort
Analysis of China's food cold chain logistics, output of quick-frozen noodles and rice products and operation of major enterprises in 2021 [figure]
聚类和分类的最基本区别。
Report on development status and investment strategy recommendations of global and Chinese graphite polystyrene board industry 2022-2028
Bcrypt password encryption kalrry
Astronomers may use pulsars to detect merged supermassive black holes
【一起上水硕系列】Day 4
3dmax软件的制作木桶过程:三步流程
Entry level use of flask
Kubernetes cluster dashboard & kuboard installation demo
Analysis on the output, market scale and development status of China's children's furniture industry in 2020 and the competition pattern of children's furniture enterprises [figure]
The Rust Programming Language
How to find happiness in programming and get lasting motivation?
Too beautiful promise because too young
Streaming a large file using PHP
弱大数定理的意义与证明