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"}]
}]
}
我發現一個辦法做到這一點。我嘗試組和聚合,但我只能推入file_name字段,因爲我搞砸了語法