Answer the question
In order to leave comments, you need to log in
How to group mongoose fields?
There is a collection:
{ "_id": "111", "area": "Omsk", "price": '500', "type:" "meal"}
{ "_id": "222", "area": "Moscow", "price": '500'," type": "meal"}
{ "_id": "333", "area": "Omsk", "price": '500', "type": "meal"}
{ "_id": "444", "area": "Moscow", "price": '500', "type": "meal"}
{
"Moscow":
{
{ "_id": "222", "price": '500'," type": "meal"},
{ "_id": "444", "price": '500', "type": "meal"}
},
"Omsk":
{
...
},
....
}
Answer the question
In order to leave comments, you need to log in
There is an aggregate api through which this can be done.
https://docs.mongodb.com/manual/reference/operator...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question