{
"_id" : ObjectId("5a4212b49e710765c486d7c6"),
"student_id" : ObjectId("5a3df85bcc6425291c54d2ad"),
"attendance_status" : true,
"create_at" : 1514279592137.0,
"__v" : NumberInt(0)
}
{
"_id" : ObjectId("5a4212b49e710765c486d7c7"),
"student_id" : ObjectId("5a3df85bcc6425291c54d2ae"),
"attendance_status" : true,
"create_at" : 1514279592137.0,
"__v" : NumberInt(0)
}
{
"_id" : ObjectId("5a4212b49e710765c486d7c9"),
"student_id" : ObjectId("5a3df85bcc6425291c54d2b0"),
"attendance_status" : true,
"create_at" : 1514279592137.0,
"__v" : NumberInt(0)
}
I store the creation time as times tramp. I want to get a data based on creation month.how to achieve it?
I am trying to find the data using the following query.
Attendance.aggregate(
[{
$project: {
create_at: "$create_at",
student_id: "$student_id",
attendance_status: "$attendance_status",
month: {
$month: "$create_at"
}
}
},
{
$match: {
"month": req.body.month
}
},
])
I want to the output based on the create month. If i send the req.body.month=3.I want the data in 3 month only.