1
我有以下的文檔結構對象的數組:
{
_id: 123,
name: 'My playlist',
videos:[
{videoId:1},
{videoId:2},
{videoId:3}]
}
現在我想做一個$lookup
影片集合中獲取所有視頻數據。最後,我需要一個數據結構是這樣的:
{
_id: 123,
name: 'My playlist',
videos:[
{videoId:1, videoDetails:[{_id:1, title:'My funny video', views:123}]},
{videoId:2, videoDetails:[{_id:2, title:'My new video', views:1234}]},
{videoId:3, videoDetails:[{_id:3, title:'Another video', views:1236}]}]
}
這可能與MongoDB的3.2和$lookup
聚集?
不,沒有關於https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/的例子。我需要爲每個單獨的對象分配「as」參數。他們將其分配給主文檔。 – user2891491