问题 I want to sum a field by using pipeline := []bson.M{ bson.M{"$group": bson.M{ "_id": "", "count": bson.M{ "$sum": 1}}} } ctx, _ := context.WithTimeout(context.Background(), 5*time.Second) result, err := collection.Aggregate(ctx, pipeline) but it always return "Current": null Any solution? 回答1: First, Collection.Aggregate() returns a mongo.Cursor, not the "direct" result. You have to iterate over the cursor to get the result documents (e.g. with Cursor.Next() and Cursor.Decode()), or use