func (e *Walkthrough) Delete(db ab.DB) error { res, err := db.Exec("UPDATE walkthrough SET published = false WHERE UUID = $1", e.UUID) if err != nil { return err } aff, err := res.RowsAffected() if err != nil { return err } if aff < 1 { return WalkthroughNotFoundError } return nil }
func (e *User) Update(db ab.DB) error { // HOOK: beforeUserUpdate() result, err := db.Exec("UPDATE \"user\" SET name = $1, mail = $2, admin = $3, created = $4, lastseen = $5 WHERE uuid = $6", e.Name, e.Mail, e.Admin, e.Created, e.LastSeen, e.UUID) if err != nil { return err } aff, err := result.RowsAffected() if err != nil { return err } if aff != 1 { return UserNotFoundError } // HOOK: afterUserUpdate() return nil }
func (e *User) Delete(db ab.DB) error { // HOOK: beforeUserDelete() res, err := db.Exec("DELETE FROM \"user\" WHERE uuid = $1", e.UUID) if err != nil { return err } aff, err := res.RowsAffected() if err != nil { return err } if aff != 1 { return UserNotFoundError } // HOOK: afterUserDelete() return nil }