Skip to content

Commit 498ed1c

Browse files
henrybarretogustavosbarreto
authored andcommitted
chore(api): move session model initialization on session get
1 parent 518d288 commit 498ed1c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

api/store/mongo/session.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,16 @@ func (s *Store) SessionGet(ctx context.Context, uid models.UID) (*models.Session
121121
})
122122
}
123123

124-
session := new(models.Session)
125-
126124
cursor, err := s.db.Collection("sessions").Aggregate(ctx, query)
127125
if err != nil {
128126
return nil, FromMongoError(err)
129127
}
128+
130129
defer cursor.Close(ctx)
131130
cursor.Next(ctx)
132131

133-
err = cursor.Decode(&session)
134-
if err != nil {
132+
session := new(models.Session)
133+
if err = cursor.Decode(&session); err != nil {
135134
return nil, FromMongoError(err)
136135
}
137136

0 commit comments

Comments
 (0)