Use both $group and $match don't work

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.0.3
    • Component/s: BSON
    • None
    • Environment:
      macOS Mojave 10.14.2
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      aggQuery := []bson.M{{
         "$group": bson.M{
            "_id": "$created_at",
            "play_sum": bson.M{
               "$sum": "$play_num",
            },
            "comment_sum": bson.M{
               "$sum": "$comment_num",
            },
         },
         "$match": []bson.M{{
            "vid": bson.M{
               "$in": bson.A{
                  "...",
                  "....",
               },
            },
         }},
      }}
      
      cursor, err := myCollection.Aggregate(ctx, aggQuery)

      i try it not work, error message:

      2019/08/11 18:56:52 (Location40323) A pipeline stage specification object must contain exactly one field.
      

       

      but i replace `aggQuery`:

      aggQuery := []bson.M{{
         "$group": bson.M{
            "_id": "$created_at",
            "play_sum": bson.M{
               "$sum": "$play_num",
            },
            "comment_sum": bson.M{
               "$sum": "$comment_num",
            },
         },
      }}

      is working.

            Assignee:
            Unassigned
            Reporter:
            cc vokia
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: