-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
Query Optimization
Currently, there is no way to share a computed expression between different fields of a $project or $addFields other than using a previous $project or $addFields. This proposes adding a let bound to precompute shared expressions. Due to the current syntax of $project and $addFields it seems we will need new pipeline stage names (or perhaps name let and projection $let and $projection?).
Unable to find source-code formatter for language: json. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
{$addFieldsShared: { let: {var1: expr1, var2: expr2, ...}, projection: {field1: expr3, field2: expr4, ...} } }
Where expr3 and expr4 can reference var1 and var2.