Aggregation in MongoDB is a tool that processes and transforms data using steps like filtering, grouping, and reshaping. It helps calculate sums, averages, and counts and can join collections. Understanding these concepts is important for making your queries efficient and solving complex problems. Interviewers often test your knowledge of these operators and how you apply them, so practicing with multiple-choice questions (MCQs) can be very helpful.
1.) What is the purpose of the MongoDB aggregation pipeline?
2.) Which aggregation stage is used to filter documents based on specified conditions?
3.) What does the $group stage do in the aggregation pipeline?
4.) What is the primary purpose of the $project stage in MongoDB?
5.) How do you specify an aggregation pipeline in MongoDB?
6.) Which operator in the $group stage is used to count the total number of documents in a group?
7.) What does the $count stage in an aggregation pipeline do?
8.) Which stage is used to sort documents in an aggregation pipeline?
9.) How do you specify a descending sort in the $sort stage?
10.) Which operator is used to calculate the average value in a $group stage?