Database
db={"suggestions":[{"_id":ObjectId("5e7d7bf7d86d85088863f4de"),"channelId":"23435553",},],"emotes":[{"suggestionId":ObjectId("5e7d7bf7d86d85088863f4de"),"emoteId":"A",},{"suggestionId":ObjectId("5e7d7bf7d86d85088863f4de"),"emoteId":"A",},{"suggestionId":ObjectId("5e7d7bf7d86d85088863f4de"),"emoteId":"B",},],"bounties":[{"suggestionId":ObjectId("5e7d7bf7d86d85088863f4de"),"userId":"user1","bountyAmount":50,},{"suggestionId":ObjectId("5e7d7bf7d86d85088863f4de"),"userId":"user1","bountyAmount":100,},{"suggestionId":ObjectId("5e7d7bf7d86d85088863f4de"),"userId":"user2","bountyAmount":200,},]}
Query
db.suggestions.aggregate([{$match:{"channelId":"23435553"}},{$lookup:{from:"emotes",localField:"_id",foreignField:"suggestionId",as:"emotes"}},{$lookup:{from:"bounties",localField:"_id",foreignField:"suggestionId",as:"bounties"}},{$project:{_id:1,channelId:1,emotes:{$arrayToObject:{$map:{input:"$emotes",as:"emote",in:{k:"$$emote.emoteId",v:{$size:{$filter:{input:"$emotes",as:"e",cond:{$eq:["$$emote.emoteId","$$e.emoteId"]}}}}}}}},bounties:{$arrayToObject:{$map:{input:"$bounties",as:"bounty",in:{k:"$$bounty.userId",v:{$sum:{$map:{input:{$filter:{input:"$bounties",as:"b",cond:{$eq:["$$bounty.userId","$$b.userId"]}}},in:"$$this.bountyAmount"}}}}}}}}}])