Database
db={"students":[{"_id":1,"name":"John"},{"_id":2,"name":"Nancy"},{"_id":3,"name":"Coco"}],"classes":[{type:"free","enrollment":[{studentID:1,other:"other value"},{studentID:3,other:"foo"}]},{type:"common","enrollment":[{studentID:1,other:"other value"},{studentID:2,other:"other value"}]}]}
Query
db.students.aggregate([{$lookup:{from:"classes",let:{id:"$_id"},pipeline:[{$match:{type:"free",$expr:{$in:["$$id","$enrollment.studentID"]}}}],as:"freeclasses"}}])