-
Type: New Feature
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Query
Arithmetic expressions in Aggregation must now be coded by hand in a rather quirky JSON prefix notation of the form {$opName: ["$field1", "$field2"]}. This becomes unwieldy and impractical with expressions of even moderate complexity, as the operands themselves become JSON subdocuments.
The server could better perform this function by accepting an expression in conventional infix operator precedence notation as used by most programming languages, of the form {$arithmetic: "field1 opSymbol field2"}. For example,
{$arithmetic: "a * b + c / (d - e)"}
would translate to
{$add:[ {$multiply: ["$a", "$b"]}, {$divide: [ "$c", {$subtract: ["$d", "$e"] ]} ]}