Shape output and derive new values.
Section: Core stages
Project computed fields
javascript
javascript
db.orders.aggregate([
{ $project: { customer_id: 1, total: 1, tax: { $multiply: ["$total", 0.08] } } }
])Explanation
`$project` is useful for output shaping and lightweight computed fields.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Core stages
Join with another collection
Use `$lookup` for collection-to-collection joins.
Run multiple result sets with $facet
Produce multiple related aggregations in one pipeline.
Count pipeline output
Return a final count after filters and transforms.