-
Type: New Feature
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
It would be useful to have a way to terminate a query with a custom error message. This would be particularly useful in the LINQ translator for the C# driver.
For example, LINQ has a method called `Single` that verifies that an array has a single element and returns that element. The query should terminate if the array is empty or has more than one element.
Assumingn the existence a `$error` operator to terminate the query, the following LINQ expression:
x.ArrayField.Single()
could be translated to something like the following MQL:
{ $switch : branches : [ { case : { $eq : [{ $size : "$ArrayFIeld" }, 0] }, then : { $error : "array is empty" } }, { case : { $gt : [{ $size : "$ArrayFIeld" }, 1] }, then : { $error : "array has more than one element" } } ], default; { $arrayElemAt : ["$ArrayField", 0] } }
- duplicates
-
SERVER-78092 Add a $error aggregate expression
- Backlog