Skip to content

$sum

Adds together numeric values and returns their total.

Syntax

{ "$sum": <arrayExpression> }

Example

Input

{ "lineItems": [29.99, 14.5, 9.0] }

Stage

{ "$project": { "orderTotal": { "$sum": "$lineItems" } } }

Output

{ "orderTotal": 53.49 }