当前位置:网站首页>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边栏推荐
猜你喜欢

Uncaught TypeError: Cannot read properties of undefined (reading ‘prototype‘)

Modify the default log level

原子Alpha开发板--SD卡和emmc烧录工具

活动报名|Apache Pulsar x KubeSphere 在线 Meetup 火热报名中

Esp8266 & sg90 steering gear & Lighting Technology & Arduino

ACWING/2004. 錯字

Cloning and importing DOM nodes

Power representation in go language

网络是怎样连接的?

弱大数定理的意义与证明
随机推荐
有能力的人从不抱怨大环境!
[acnoi2022] the structure of President Wang
Pratique de gestion hiérarchique basée sur kubesphere
Entry level use of flask
Change the current count of auto increment values in MySQL- Changing the current count of an Auto Increment value in MySQL?
Hongmeng learning notes: creating layouts using XML
[learn shell programming easily]-5. Plan tasks
Coffee script unmatched outent error
Why did Yanjing Beer come here?
StreamNative Platform 1.5 版本发布,集成 Istio、支持 OpenShift 部署
Blue Bridge Cup SCM module code (timer) (code + comments)
Clearing Magento log data - clearing Magento log data
【2022黑马程序员】SQL优化
In depth analysis of Apache bookkeeper series: Part 3 - reading principle
1W字|40 图|硬核 ES 实战
Acwing / 2004. Mauvaise écriture
了解zbrush雕刻软件,以及游戏建模的分析
We are different
Wow, it's so rich.
Leetcode 2163. Minimum difference of sum after element deletion