diff --git a/internal/storage/gift_mongo.go b/internal/storage/gift_mongo.go index 34dc04b..764b5bd 100644 --- a/internal/storage/gift_mongo.go +++ b/internal/storage/gift_mongo.go @@ -55,6 +55,12 @@ func (r *MySQLRepository) listMongoGiftAmounts(ctx context.Context, db *mongo.Da {Key: "_id", Value: bson.D{{Key: "userId", Value: "$userId"}, {Key: "day", Value: "$day"}}}, {Key: "amount", Value: bson.D{{Key: "$sum", Value: "$amount"}}}, }}}, + bson.D{{Key: "$project", Value: bson.D{ + {Key: "_id", Value: 0}, + {Key: "userId", Value: "$_id.userId"}, + {Key: "day", Value: "$_id.day"}, + {Key: "amount", Value: "$amount"}, + }}}, ) cursor, err := db.Collection(giftRunningWaterCollection).Aggregate(ctx, pipeline) if err != nil { @@ -67,9 +73,8 @@ func (r *MySQLRepository) listMongoGiftAmounts(ctx context.Context, db *mongo.Da if err := cursor.Decode(&doc); err != nil { return nil, err } - idDoc, _ := doc["_id"].(bson.M) - userID := bsonInt64(idDoc["userId"]) - day := strings.TrimSpace(fmt.Sprint(idDoc["day"])) + userID := bsonInt64(doc["userId"]) + day := strings.TrimSpace(fmt.Sprint(doc["day"])) amount := bsonDecimal(doc["amount"]) if userID == 0 || day == "" { continue