Skip to content

Commit dacfe7c

Browse files
committed
Nil pointer will be coalesed to 0
1 parent 52c1354 commit dacfe7c

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

graphql/graph/section.resolvers.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ func (r *queryResolver) Sections(
3939
}
4040

4141
// pagination logic
42-
skip := int64(0)
43-
if offset != nil {
44-
skip = int64(*offset)
45-
}
46-
paginate := options.Find().
47-
SetSkip(skip).
48-
SetLimit(configs.GetEnvLimit())
42+
paginate := options.Find().SetSkip(int64(*offset)).SetLimit(configs.GetEnvLimit())
4943

5044
// query database
5145
cursor, err := r.SectionCollection.Find(timeoutCtx, sectionQuery, paginate)
@@ -79,7 +73,8 @@ func (r *queryResolver) Section(ctx context.Context, id string) (*model.Section,
7973

8074
// decoding to a real value and not a nullptr
8175
var dbSection model.DBSection
82-
if err := r.SectionCollection.FindOne(timeoutCtx, bson.M{"_id": objectId}).Decode(&dbSection); err != nil {
76+
if err := r.SectionCollection.FindOne(
77+
timeoutCtx, bson.M{"_id": objectId}).Decode(&dbSection); err != nil {
8378
return nil, err
8479
}
8580

0 commit comments

Comments
 (0)