0
정확하고 잘못되었거나 시도되지 않은 질문 수를 계산하고 싶습니다. 저는 제로 값을 얻고 있습니다.쿼리로 MongoDB 중첩 그룹
쿼리 -
db.studentreports.aggregate([
{ $match: { 'groupId': 314 } },
{ $unwind: '$questions' },
{ $group:
{
_id: {
dateTimeStamp: '$dateTimeStamp',
customerId: '$customerId'
},
questions : { $push: '$questions' },
unttempted : { $sum : { $eq: ['$questions.status',0]}},
correct : { $sum : { $eq: ['$questions.status',1]}},
incorrect : { $sum : { $eq: ['$questions.status',2]}},
Total: { $sum: 1 }
}
}
])
스키마 구조 - unttempted 정확하고 잘못된
{
"_id" : ObjectId("59fb46ed560e1a2fd5b6fbf4"),
"customerId" : 2863318,
"groupId" : 309,
"questions" : [
{
"questionId" : 567,
"status" : 0,
"_id" : ObjectId("59fb46ee560e1a2fd5b700a4"),
},
{
"questionId" : 711,
"status" : 0,
"_id" : ObjectId("59fb46ee560e1a2fd5b700a3")
},
....
값이 잘못지고있다 -
"unttempted": 0, 을 "올바른": 0, "incorrect": 0, "Total": 7558.0
그룹화 기준은 datetime 및 customerId를 기준으로합니다. 몇 가지 올바른 쿼리를 사용할 수 있습니까? 감사합니다. .