2023-09-10 15:39:34 +00:00
|
|
|
package db
|
|
|
|
|
2023-10-04 11:36:54 +00:00
|
|
|
func (db *DB) CreateSession(s *Session) error {
|
2023-09-10 15:39:34 +00:00
|
|
|
_, err := db.Exec("INSERT INTO sessions(pubkey, session_id) VALUES($1, $2)", s.Pubkey, s.SessionId)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-10-04 11:36:54 +00:00
|
|
|
func (db *DB) FetchSession(s *Session) error {
|
2023-09-10 15:39:34 +00:00
|
|
|
err := db.QueryRow("SELECT pubkey FROM sessions WHERE session_id = $1", s.SessionId).Scan(&s.Pubkey)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-10-04 11:36:54 +00:00
|
|
|
func (db *DB) DeleteSession(s *Session) error {
|
2023-09-10 15:39:34 +00:00
|
|
|
_, err := db.Exec("DELETE FROM sessions where session_id = $1", s.SessionId)
|
|
|
|
return err
|
|
|
|
}
|