Skip to content

Commit

Permalink
use cursor.Next() over All()
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatoleAM committed Dec 15, 2023
1 parent 493a5cc commit 8bb8a27
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions data/query/query.emote-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"sort"

"github.com/hashicorp/go-multierror"
"github.com/seventv/common/errors"
"github.com/seventv/common/mongo"
"github.com/seventv/common/structures/v3"
"github.com/seventv/common/structures/v3/aggregations"
Expand All @@ -31,10 +30,17 @@ func (q *Query) EmoteSets(ctx context.Context, filter bson.M, opts ...QueryEmote

defer cur.Close(ctx)

if err = cur.All(ctx, &items); err != nil {
zap.S().Errorw("mongo, failed to fetch emote sets", "error", err)
for cur.Next(ctx) {
var item structures.EmoteSet

return qr.setError(errors.ErrInternalServerError())
if err := cur.Decode(&item); err != nil {
zap.S().Errorw("failed to decode emote sets", "error", err)
qr.setError(err)

return qr
}

items = append(items, item)
}

shouldGetOrigin := false
Expand Down

0 comments on commit 8bb8a27

Please sign in to comment.