Database
db={"post":[{_id:ObjectId("5fce0e137ff7401634bad2ac"),address:"new york",description:"this is a great city",image:"test1.jpg",userId:"5fcdcd8487e37216bc82171b"}],"user":[{_id:ObjectId("5fcdcd8487e37216bc82171b"),name:"jack",profile:{image:"test2.jpg",description:"be happy dude"},email:"test@test.com",password:"2a$12$gzRrY83QAjwLhdyvn3JQ2OcMj3XG65.BULva4cZqcuSxDhhMbSXCq"}],"likeComments":[{_id:ObjectId("aaaaaaaaaaaaaaaaaaaaaaaa"),likes:{quantity:1,likes:[{isActive:true,userId:"5fcdcd8487e37216bc82171b"}]},comments:{quantity:1,comments:[{userId:"5fcdcd8487c31216cc87886r",comment:"awesome city"}]},postId:"5fce0e137ff7401634bad2ac"}]}
Query
db.post.aggregate([/** {*//** $match: {*//** userId: {*//** $in: users.map(u=>u)*//** }*//** }*//** },*/{$project:{_id:0,userId:{$toObjectId:"$userId"},postId:{$toString:"$_id"},location:"$address",description:"$description",image:"$image"}},{$lookup:{from:"user",localField:"userId",foreignField:"_id",as:"userInfo"}},{$unwind:"$userInfo"},{$project:{_id:0,postId:1,location:1,description:1,image:1,userId:{$toString:"$userId"},name:"$userInfo.name",profile:"$userInfo.profile.image"}},{$lookup:{from:"likeComments",localField:"postId",foreignField:"postId",as:"likesComments"}},{$unwind:"$likesComments"},{$project:{postId:1,location:1,description:1,image:1,userId:1,name:1,profile:1,likes:{$map:{input:"$likesComments.likes.likes",as:"item",in:"$$item.userId"}},quantity:"$likesComments.comments.quantity",comments:{comments:{$map:{input:"$likesComments.comments.comments",as:"item",in:"$$item.userId"}}}}},/**...*/])