[GODRIVER-1228] Use both $group and $match don't work Created: 11/Aug/19  Updated: 11/Sep/19  Resolved: 13/Aug/19

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: 1.0.3
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: cc vokia Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

macOS Mojave 10.14.2



 Description   

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.



 Comments   
Comment by Esha Bhargava [ 13/Aug/19 ]

wsadwsadqe@hotmail.comThanks for your report. Please note that this project is for reporting bugs or feature suggestions for the driver. For MongoDB-related support discussion please post on the [mongodb-user group|http://groups.google.com/group/mongodb-user] or [Stack Overflow with the mongodb tag|http://stackoverflow.com/questions/tagged/mongodb]. A question like this involving more discussion would be best posted on the mongodb-users group. 

Generated at Thu Feb 08 08:35:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.