{
"_id" : ObjectId("606b7031a0ccf722226a85ae"),
"groupId" : ObjectId("5f06cca74e51ba15f5167b86"),
"insertedAt" : "2021-04-05T20:16:49.893343Z",
"isActive" : true,
"staffId" : [
"606b6b44a0ccf72222ce375a"
],
"subjectName" : "English",
"teamId" : ObjectId("6069a6a9a0ccf704e7f4b537"),
"updatedAt" : "2021-04-05T20:16:49.893382Z",
"syllabus" : [
{
"chapterId" : "627f4e05ae6cd20cefbe3bb1",
"chapterName" : "chap1",
"topicsList" : [
{
"topicId" : "627f4e05ae6cd20cefbe3bb2",
"topicName" : "1.1"
},
{
"topicId" : "627f4e05ae6cd20cefbe3bb3",
"topicName" : "2.5"
}
]
},
{
"chapterId" : "627f4e05ae6cd20cefbe3bb4",
"chapterName" : "chap2",
"topicsList" : [
{
"topicId" : "627f4e05ae6cd20cefbe3bb5",
"topicName" : "1"
},
{
"topicId" : "627f4e05ae6cd20cefbe3bb6",
"topicName" : "2"
}
]
}
],
"updateAt" : "2022-05-14T06:36:53.981765Z"
}
mongo query
db.subject_staff_database.aggregate({$project: { numberOfCourses: { $size: "$syllabus" }}})
Result
uncaught exception: Error: command failed: {
"ok" : 0,
"errmsg" : "The argument to $size must be an array, but was of type: missing",
"code" : 17124,
"codeName" : "Location17124"
} : aggregate failed :