Extended $lookup

Simply

db.devices.find( { "group.$id" : 11 } ).projection( { _id : 1 } )

will produce a list of distinct _id (because _id is always unique within a collection as already mentioned) of the devices of the group 11.

2 Likes