Switched to purer libraries
This commit is contained in:
parent
8fa8bb4c3a
commit
9496947f01
21 changed files with 390 additions and 316 deletions
17
section.go
17
section.go
|
|
@ -2,9 +2,10 @@ package main
|
|||
|
||||
import (
|
||||
// External
|
||||
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||
werr "git.ahall.se/go/wrappederror"
|
||||
|
||||
// Standard
|
||||
"context"
|
||||
"sort"
|
||||
)
|
||||
|
||||
|
|
@ -26,20 +27,26 @@ func (s *Section) SortedTriggers() []Trigger {
|
|||
}
|
||||
|
||||
func SectionCreate(areaID int, name string) (err error) { // {{{
|
||||
_, err = service.Db.Conn.Exec(`INSERT INTO section(area_id, name) VALUES($1, $2)`, areaID, name)
|
||||
_, err = db.Exec(context.Background(), `INSERT INTO section(area_id, name) VALUES($1, $2)`, areaID, name)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
}
|
||||
return
|
||||
} // }}}
|
||||
func SectionRename(id int, name string) (err error) { // {{{
|
||||
_, err = service.Db.Conn.Exec(`UPDATE section SET name=$2 WHERE id=$1`, id, name)
|
||||
_, err = db.Exec(context.Background(), `UPDATE section SET name=$2 WHERE id=$1`, id, name)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
}
|
||||
return
|
||||
} // }}}
|
||||
func SectionDelete(id int) (err error) { // {{{
|
||||
_, err = service.Db.Conn.Exec(`DELETE FROM public.trigger WHERE section_id = $1`, id)
|
||||
_, err = db.Exec(context.Background(), `DELETE FROM public.trigger WHERE section_id = $1`, id)
|
||||
if err != nil {
|
||||
return werr.Wrap(err).WithData(id)
|
||||
}
|
||||
|
||||
_, err = service.Db.Conn.Exec(`DELETE FROM public.section WHERE id = $1`, id)
|
||||
_, err = db.Exec(context.Background(), `DELETE FROM public.section WHERE id = $1`, id)
|
||||
if err != nil {
|
||||
return werr.Wrap(err).WithData(id)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue