Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- db.feedbacks.aggregate([
- {$match : {
- "collection": "tests",
- "docId": {$in : [ObjectId("56c6dc8a995a2d6dc85f45eb") , ObjectId("5abcaf934e04790c26cad289"), ObjectId("56c6de2b995a2d6dc85f4828")]}
- }
- },
- {$unwind : "$mo"},
- {
- $lookup : {
- from : "feedback_options",
- localField: "mo",
- foreignField: "_id",
- as : "option_details"
- }
- },
- {$project : {
- "mo": 1,
- "option_details": {$arrayElemAt: ["$option_details", 0]},
- "rating": 1
- }
- },
- {$match : {"rating": {$in : [1, 2, 3, 4,5]}}},
- {$group :
- {
- _id: "$mo",
- count : {$sum : 1},
- optionText : {$first : "$option_details.text"},
- ratings : {$addToSet : "$rating"}
- }
- }
- ])
Advertisement
Add Comment
Please, Sign In to add comment