Database

db={"communities":[{"communityId":"communityId1","name":"community1"},{"communityId":"communityId2","name":"community2"},{"communityId":"communityId3","name":"community3"}],"users":[{"userId":"userId1","userName":"test1",},{"userId":"userId2","userName":"test2",}],"follows":[{"communityId":"communityId1","userId":"userId2","name":"community3",},{"communityId":"communityId2","userId":"userId1","name":"community2",},{"communityId":"communityId3","userId":"userId1","name":"community1",}],}

Query

db.communities.aggregate([{$lookup:{from:"follows",localField:"communityId",foreignField:"communityId",as:"follows",},},{$unwind:"$follows",},{$lookup:{from:"users",let:{userId:"$follows.userId",},pipeline:[{$match:{userId:"userId1",$expr:{$eq:["$userId","$$userId"],},},},],as:"users",},},{$unwind:"$users",},{$project:{name:1,},},])

Result