seniorMongoDB
Explain the difference between $map and $reduce in aggregation.
Updated May 1, 2026
Short answer
$map applies an expression to each element of an array; $reduce collapses an array into a single value.
Deep explanation
They are used within the $project or $addFields stages for complex array manipulation without leaving the pipeline.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro