You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
541 B
Go

package dbi
import (
"context"
"database/sql"
"fmt"
)
func MarkPosted(conn *sql.Conn, uid string) error {
for _, table := range []string{"scholarship", "activities", "appearances"} {
res, err := conn.ExecContext(context.Background(),
"UPDATE "+table+" SET Status = 'posted' WHERE UID = ? AND Status = 'reported'",
uid,
)
if err != nil {
return err
}
n, err := res.RowsAffected()
if err != nil {
return err
}
if n > 0 {
return nil
}
}
return fmt.Errorf("UID %q not found among reported items", uid)
}