일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- self-signed
- CJ대한통운 #쿠팡 #통관번호오류 #통관고유번호오류 #안주원팀장 #모건인베스트
- 보이스피싱 #대검찰청 #명의도용 #비밀번호 #계좌번호 #공공기관 #가짜검찰청
- 중고나라
- XSS
- intelmac
- speed-measure-webpack-plugin
- NUGU
- MongoDB #NoSQL #CreateUser #DropUser #mongod #mognod.conf
- 모의해킹
- Frida
- 거래사기
- react
- 변태는
- shell_gpt
- 많다..
- open redirect
- CryptoJS
- 척추관협착증
- 허리디스크
- ue4dumper
- 취약점
- Sequoia
- 안전결제
- Malware Sample
- 로맨스스캠
- 네이버카페
- 채팅환전사기
- esbuild
- ssrf
Archives
- Today
- Total
annyoung
mongodb combine two queries with aggregate 본문
Use $facet
when you wanna combine two queries
[
{
"$facet": {
"all": [
{
"$match": {
"project": ObjectId("61d533c23186e90323d116c3"),
}
},
{"$count": "TotalCount"},
],
"completed": [
{
"$match": {
"project": ObjectId("61d533c23186e90323d116c3"),
"$or": [
{"status": "CONSIGNMENT_SUBMIT"},
{"status": "AGENCY_SUBMIT"},
]
}
},
{"$count": "TotalCount"},
],
"noResponse": [
{
"$match": {
"project": ObjectId("61d533c23186e90323d116c3"),
"status": "DEPLOY_OK",
}
},
{"$count": "TotalCount"},
],
"onGoing": [
{
"$match": {
"project": project_id,
"$or": [
{"status": "CONSIGNMENT_START"},
{"status": "RETAKE"},
{"status": "AGENCY_START"},
]
}
},
{"$count": "TotalCount"},
],
}
},
{"$unwind": "$all"},
{"$unwind": "$completed"},
{"$unwind": "$noResponse"},
{"$unwind": "$onGoing"},
{
"$project": {
"all": "$all.TotalCount",
"completed": "$completed.TotalCount",
"noResponse": "$noResponse.TotalCount",
"onGoing": "$onGoing.TotalCount"
}
}
]
'데이터베이스' 카테고리의 다른 글
MongoDB 유저생성 및 데이터베이스 생성 (0) | 2019.01.08 |
---|---|
Install MongoDB + phpMongoDriver in Mac OSX High Sierra (0) | 2018.09.13 |
[mongodb] how to find dictionary not null (0) | 2018.04.30 |
mongodb not authorized? how to create database in mongodb (0) | 2018.04.18 |
Comments