I have document collections like these
{ "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"}
I need a result as an object like this
{
[{
"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"}]
}]
}
I'm finding a way to do this. I've try group and aggregate but I can only push file_name field in because I mess up with syntax