i am trying to use aggregate till now i am successfull to get the data but i got a issue that how i can get the data unread. this is my mongo db, i want to extract data according to my requirement
{
"_id": ObjectId("5912c7240520df77f0c2c18a"),
"email_id": "54",
"unread": "false",
"__v": NumberLong(0),
"tag_id": ["0"
]
}, {
"_id": ObjectId("5912c71e0520df77f0c2c189"),
"email_id": "55",
"unread": "false",
"__v": NumberLong(0),
"tag_id": [
"1"
]
}, {
"_id": ObjectId("5912c71d0520df77f0c2c186"),
"email_id": "51",
"unread": "false",
"__v": NumberLong(0),
"tag_id": [
"2", "1"
]
}
expected result:
{
"data": [{
"tag_id": "1",
"count_email": 1,
"unread": 9
}, {
"tag_id": "3",
"count_email": 45,
"unread": 3
}, {
"tag_id": "2",
"count_email": 5,
"unread": 4
}, {
"id": null,
"count_email": 52,
"unread": 35
}]
}
via Shekhar Tyagi
No comments:
Post a Comment