Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-14872

Aggregation Pipeline in Custom Resolver Example is buggy

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • Realm
    • None
    • 3

    Description

      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
      }}]
      

       

       

      Attachments

        Activity

          People

            nick.larew@mongodb.com Nicholas Larew
            philip.eschenbacher@mongodb.com Philip Eschenbacher
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              2 years, 16 weeks, 1 day ago