-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Realm
-
Labels:None
-
3
In the Realm documentation in the section "Define a Customer Resolver" is an error in the aggregation pipeline that is embedded in the function example which should resolve the result set.
https://docs.mongodb.com/realm/graphql/custom-resolvers/#custom-query-resolver
The actual pipeline is not working and resolves to an annoying error which is hard to find out when you try to work with the example.
The correct pipeline in this function should look like this to work:
[{$match: { month: month, year: year }}, {$group: { _id: { month: "$month", year: "$year" }, averageSale: { $avg: "$saleTotal" } }}, {$project: { month: "$_id.month", year: "$_id.year", averageSale: 1 }}]