[DOCS-7368] Comment on: "manual/reference/operator/aggregation/map.txt" Created: 08/Mar/16  Updated: 14/Dec/16  Resolved: 31/Mar/16

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: David Banks Assignee: Steve Renaker (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

NA

Location: https://docs.mongodb.org/manual/reference/operator/aggregation/map/#exp._S_map
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Referrer: https://docs.mongodb.org/manual/reference/operator/aggregation-projection/
Screen Resolution: 1920 x 1080
repo: docs
source: reference/operator/aggregation/map


Issue Links:
Duplicate
is duplicated by DOCS-7367 Comment on: "manual/reference/operato... Closed
Participants:
Days since reply: 7 years, 45 weeks, 6 days ago

 Description   

NB, Correction for https://jira.mongodb.org/browse/DOCS-7367

I think the $add below should be a $mul.

db.sales.aggregate( [
{
$project: {
finalTotal: {
$let: {
vars: {
total:

{ $add: [ '$price', '$tax' ] }

,
discounted: { $cond:

{ if: '$applyDiscount', then: 0.9, else: 1 }

}
},
in:

{ $multiply: [ "$$total", "$$discounted" ] }

}
}
}
}
] )



 Comments   
Comment by Steve Renaker (Inactive) [ 31/Mar/16 ]

I believe this example is correct as written. The price and the tax are intended to be added, not multiplied. Thanks for getting involved, and let us know if this still doesn't seem right to you.

Generated at Thu Feb 08 07:54:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.