21 lines
570 B
Go
21 lines
570 B
Go
|
package db
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
func HasStarredBefore(discordID string) (bool, error) {
|
||
|
rows, err := db.Query("SELECT id FROM starred WHERE id=?", discordID)
|
||
|
if err != nil {
|
||
|
return true, fmt.Errorf("db: HasStarredBefore: underlying SQL error on 'select' (%s): %w", discordID, err)
|
||
|
}
|
||
|
defer rows.Close()
|
||
|
return rows.Next(), nil
|
||
|
}
|
||
|
|
||
|
func SetStarred(discordID string) error {
|
||
|
_, err := db.Exec("INSERT INTO starred(id) VALUES(?)", discordID)
|
||
|
if err != nil {
|
||
|
return fmt.Errorf("db: SetStarred: underlying SQL error on 'insert' (%s): %w", discordID, err)
|
||
|
}
|
||
|
return nil
|
||
|
}
|