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.
|