I have user document collection like this:
User {
id:\"001\"
name:\"John\",
age:30,
friends:[\"userId1\",\"userId2\",\"userId3\"....]
}
>
one kind of join a query in mongoDB, is ask at one collection for id that match , put ids in a list (idlist) , and do find using on other (or same) collection with $in : idlist
u = db.friends.find({"friends": ? }).toArray()
idlist= []
u.forEach(function(myDoc) { idlist.push(myDoc.id ); } )
db.friends.find({"id": {$in : idlist} } )