From 6546a4d81949da46fb242aded5ba934bb731024b Mon Sep 17 00:00:00 2001 From: anatoleam Date: Fri, 15 Dec 2023 16:48:27 +0100 Subject: [PATCH] change cursor behavior at query/cosmetics --- data/query/query.cosmetics.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/data/query/query.cosmetics.go b/data/query/query.cosmetics.go index 08c1ec5b..635e5e1f 100644 --- a/data/query/query.cosmetics.go +++ b/data/query/query.cosmetics.go @@ -11,6 +11,7 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" mongod "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" + "go.uber.org/zap" ) func (q *Query) Cosmetics(ctx context.Context, ids utils.Set[primitive.ObjectID]) ([]structures.Cosmetic[bson.Raw], error) { @@ -37,8 +38,16 @@ func (q *Query) Cosmetics(ctx context.Context, ids utils.Set[primitive.ObjectID] return nil, err } - if err = cur.All(ctx, &result); err != nil { - return nil, err + for cur.Next(ctx) { + var cos structures.Cosmetic[bson.Raw] + + if err := cur.Decode(&cos); err != nil { + zap.S().Errorw("failed to decode cosmetics", "error", err) + + return nil, err + } + + result = append(result, cos) } // Set cache