아래 내 스키마입니다. 내 'file_id'(내 file_id를 정의 할 것입니다.) 다른 'user_email'.. 계산해야합니다. 비슷한 및 다른 user_email 함께 file_id 수를 메모가 없습니다. 서로 다른 user_email.any 도움말을 사용하여 내 file_id의 개수를 계산 하시겠습니까? 다음과 같이 그런 다음에야 당신은 단순히 결과를 필터링 할 수 있습니다 특정 file_id
에 관심이 있다면mongoDb에서 다른 값을 찾고 그룹화하는 방법은 무엇입니까?
{
"_id" : ObjectId("591bedc8c942a3514ed09b24"),
"file_id" : "58450c20b053dc426b935927",
"description" : "get your output ready",
"user_email" : "[email protected]",
"__v" : 0
}
{
"_id" : ObjectId("591bedc8c942a3514ed09b25"),
"description" : "get your output ready",
"user_email" : "[email protected]",
"__v" : 0
}
{
"_id" : ObjectId("591bedc8c942a3514ed09b26"),
"file_id" : "58450c20b053dc426b935927",
"description" : "get your output ready",
"user_email" : "[email protected]",
"__v" : 0
}
{
"_id" : ObjectId("591bedc8c942a3514ed09b27"),
"file_id" : "58450c20b053dc426b935927",
"description" : "get your output ready",
"user_email" : "[email protected]",
"__v" : 0
}
{
"_id" : ObjectId("591beea4a62559b4506549e0"),
"file_id" : "58450c20b053dc426b935927",
"description" : "get your output ready",
"user_email" : "[email protected]",
"__v" : 0
}
db.myschema.aggregate({$group:{"file_id":"58450c20b053dc426b935927","user_email" : "[email protected]",count: { $sum: 1 }} })
귀하의 질문에 명확하지 않습니다. – Lekhnath
나는 다른 사용자 이메일로 내 쿼리를 정의하고있는 파일 아이디의 개수를 가져와야합니다. 동일한 file_id 및 동일한 user_email이있는 10 개의 레코드가있는 경우 1로 계산되고 10으로 계산되어야합니다. – Jagadeesh