create/delete organization handlers (#537)

This commit is contained in:
Michael Quigley
2024-12-09 13:30:45 -05:00
parent 38b32d15d0
commit c98aaa8e00
8 changed files with 200 additions and 0 deletions

View File

@ -23,6 +23,14 @@ func (str *Store) CreateOrganization(org *Organization, trx *sqlx.Tx) (int, erro
return id, nil
}
func (str *Store) FindOrganizationByToken(token string, trx *sqlx.Tx) (*Organization, error) {
org := &Organization{}
if err := trx.QueryRowx("select * from organizations where token = $1", token).StructScan(org); err != nil {
return nil, errors.Wrap(err, "error selecting frontend by token")
}
return org, nil
}
func (str *Store) DeleteOrganization(id int, trx *sqlx.Tx) error {
stmt, err := trx.Prepare("update organizations set updated_at = current_timestamp, deleted = true where id = $1")
if err != nil {