0
У меня есть коллекции документов, как этиКак группировать объекты из коллекции MongoDB
{ "owner": "550511223", "file_name": "55234OT01", "file_type": "other", "comment": "Just fix it"},
{ "owner": "550510584", "file_name": "55584RS01", "file_type": "resume", "comment": "Good enough"},
{ "owner": "550511223", "file_name": "55234AP01", "file_type": "applicant", "comment": "This will do"}
Мне нужен результат как объект, как это
{
[{
"owner" : "550510584",
"files" : [{"file_name": "55584RS01","file_type": "resume","comment": "Good enough"}],
},{
"owner" : "550511234",
"files" : [{"file_name": "55234AP01","file_type": "applicant","comment": "This will do"},
{"file_name": "55234OT01","file_type": "other","comment": "Just fix it"}]
}]
}
Я найти способ сделать это. Я попробовал группу и агрегацию, но я могу только указать имя_файла в поле, потому что я испортил синтаксис