c66e96bf3f
* fix init misuse which makes running tests impossible since tests are run inside a temporary test directory which breaks env loading * use dependency injection pattern for server creation and global server context in route handlers
17 lines
480 B
Go
17 lines
480 B
Go
package db
|
|
|
|
func (db *DB) CreateSession(s *Session) error {
|
|
_, err := db.Exec("INSERT INTO sessions(pubkey, session_id) VALUES($1, $2)", s.Pubkey, s.SessionId)
|
|
return err
|
|
}
|
|
|
|
func (db *DB) FetchSession(s *Session) error {
|
|
err := db.QueryRow("SELECT pubkey FROM sessions WHERE session_id = $1", s.SessionId).Scan(&s.Pubkey)
|
|
return err
|
|
}
|
|
|
|
func (db *DB) DeleteSession(s *Session) error {
|
|
_, err := db.Exec("DELETE FROM sessions where session_id = $1", s.SessionId)
|
|
return err
|
|
}
|