Pipeline Practice

Calculate every line total

`$map` runs one expression for every element of an array and returns the transformed values as a new array. The named variable uses a double-dollar field path such as `$item.qty`.

Add a `lineTotals` array to every order. Each entry must equal that item’s quantity multiplied by its unit price.

Expected result: Every order keeps its original fields and gains one correctly ordered line total per item.

Example pipeline syntax

[
  { $set: { lineTotals: "$items" } }
]