diff options
Diffstat (limited to '')
-rw-r--r-- | internal/storage/session.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/storage/session.go b/internal/storage/session.go index fb78ea02..cf48b5aa 100644 --- a/internal/storage/session.go +++ b/internal/storage/session.go @@ -70,6 +70,23 @@ func (s *Storage) UpdateAppSessionField(sessionID, field string, value any) erro return nil } +func (s *Storage) UpdateAppSessionObjectField(sessionID, field string, value interface{}) error { + query := ` + UPDATE + sessions + SET + data = jsonb_set(data, '{%s}', $1, true) + WHERE + id=$2 + ` + _, err := s.db.Exec(fmt.Sprintf(query, field), value, sessionID) + if err != nil { + return fmt.Errorf(`store: unable to update session field: %v`, err) + } + + return nil +} + // AppSession returns the given session. func (s *Storage) AppSession(id string) (*model.Session, error) { var session model.Session |