$lookup on ObjectId's in an array

后端 未结 6 1644
忘了有多久
忘了有多久 2020-11-22 04:53

What\'s the syntax for doing a $lookup on a field that is an array of ObjectIds rather than just a single ObjectId?

Example Order Document:

{
  _id:          


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 05:26

    Starting with MongoDB v3.4 (released in 2016), the $lookup aggregation pipeline stage can also work directly with an array. There is no need for $unwind any more.

    This was tracked in SERVER-22881.

提交回复
热议问题