I am pretty new to mongoose aggregation and I have the collection in the below format
Collection Documents:
{
"movie":"Fast and Furious",
"rating":"Good",
"ratingTime":"2015-3-06 4:05:10"
},
{
"movie":"Avengers Infinity Stones",
"rating":"Very Good",
"ratingTime":"2020-20-4 22:10:40"
},
{
"movie":"Mad Max Fury Road",
"rating":"Average",
"ratingTime":"2015-3-06 15:23:25"
},
{
"movie":"Toy story",
"rating":"Good",
"ratingTime":"2020-20-4 10:11:02"
}
I want it in the below format :
[
{
"2015-3-06":[{
"movie":"Fast and Furious",
"rating":"Good",
"ratingTime":"2015-3-06 4:05:10"
},{
"movie":"Mad Max Fury Road",
"rating":"Average",
"ratingTime":"2015-3-06 15:23:25"
}]
},
{
"2020-20-4":[{
"movie":"Avengers Infinity Stones",
"rating":"Very Good",
"ratingTime":"2020-20-4 22:10:40"
},{
"movie":"Toy story",
"rating":"Good",
"ratingTime":"2020-20-4 10:11:02"
}]
}
]
Can somebody please help me as I am not getting any ideas to get the output in desired format. Really appreciate for the help