Implement DELETE /task/{taskId} (#51)

Close #47

Reviewed-on: #51
This commit was merged in pull request #51.
This commit is contained in:
2025-05-15 18:08:54 +02:00
parent 8fedac21bb
commit d1774c1ce0
3 changed files with 77 additions and 0 deletions

View File

@@ -221,6 +221,21 @@ func (db *Db) GetTask(id int) (Task, error) {
return task, nil
}
func (db *Db) DeleteTask(id int) error {
tx, err := db.db.Begin()
if err != nil {
return err
}
defer tx.MustRollback()
err = tx.Query("delete from tasks where id = ?").Bind(id).Exec()
if err != nil {
return err
}
return tx.Commit()
}
func (db *Db) HasTask(id int) (bool, error) {
count := 0
err := db.db.Query("select count(*) from tasks where id = ?").