summaryrefslogtreecommitdiff
path: root/golang/pkg/database/tokens.go
blob: 16bda2b3ca6503d7ae67e2cd83ee6e9ae884caa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package database

func (db DB) AddToken(token string) error {
	_, err := db.db.ExecContext(db.ctx, `INSERT INTO tokens(data) VALUES (?);`, token)
	return err
}

func (db DB) GetToken() (string, error) {
	var token string
	if err := db.db.QueryRowContext(db.ctx, `SELECT data FROM tokens;`).Scan(&token); err != nil {
		return "", err
	}
	return token, nil
}