Skip to content

Commit

Permalink
change cursor behavior at query/cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatoleAM committed Dec 15, 2023
1 parent 905c758 commit 6546a4d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions data/query/query.cosmetics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 6546a4d

Please sign in to comment.