oficina / base Public

Clone
git clone https://amadan.net/oficina/base

Plain git — no account needed to clone.

Download

Download this file

1package store
2
3import (
4 "context"
5 "database/sql"
6 "fmt"
7)
8
9// SetTheme keeps the member's Appearance: "" (the device's), "light" or
10// "dark". The caller checks the value.
11func SetTheme(ctx context.Context, db *sql.DB, memberID, theme string) error {
12 res, err := db.ExecContext(ctx, `UPDATE members SET theme = ? WHERE id = ?`, theme, memberID)
13 if err != nil {
14 return err
15 }
16 if n, err := res.RowsAffected(); err != nil {
17 return err
18 } else if n != 1 {
19 return fmt.Errorf("store: no member %s", memberID)
20 }
21 return nil
22}
23