| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 29 | 30 | 31 |
Tags
- S3
- jeb_mcp
- speed-measure-webpack-plugin
- aes
- mitmproxy
- esbuild
- Sequoia
- 모의해킹
- 많다..
- 내부확산
- AWS
- Frida
- 채팅환전사기
- 허리디스크
- 취약점
- Malware Sample
- intelmac
- ue4dumper
- 척추관협착증
- shell_gpt
- 안전결제
- 변태는
- react2shell
- XSS
- self-signed
- cve-2025-55182
- 네이버카페
- EC2
- 중고나라
- LFI
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"
}
}
]
'데이터베이스' 카테고리의 다른 글
| AWS CPUUtilization (0) | 2026.01.12 |
|---|---|
| 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
