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 pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More MongoDB interview questions

View all →