From dd7ebf150907c9f0fb6fc8568b6fea3de154c550 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 12 Oct 2015 10:46:07 -0700 Subject: [PATCH] Delete strains --- api/strains.go | 10 ++++++++++ handlers/handlers.go | 1 + 2 files changed, 11 insertions(+) diff --git a/api/strains.go b/api/strains.go index 15b8b6f..93d6d2f 100644 --- a/api/strains.go +++ b/api/strains.go @@ -217,3 +217,13 @@ func (s StrainService) Create(e *types.Entity, genus string, claims *types.Claim return nil } + +// Delete deletes a single strain +func (s StrainService) Delete(id int64, genus string, claims *types.Claims) *types.AppError { + q := `DELETE FROM strains WHERE id=$1;` + // TODO: fix this + if _, err := models.DBH.Exec(q, id); err != nil { + return newJSONError(err, http.StatusInternalServerError) + } + return nil +} diff --git a/handlers/handlers.go b/handlers/handlers.go index f5eda7b..55064a2 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -79,6 +79,7 @@ func Handler() http.Handler { r{handleCreater(strainService), "POST", "/strains"}, r{handleGetter(strainService), "GET", "/strains/{ID:.+}"}, r{handleUpdater(strainService), "PUT", "/strains/{ID:.+}"}, + r{handleDeleter(strainService), "DELETE", "/strains/{ID:.+}"}, r{handleLister(characteristicService), "GET", "/characteristics"}, r{handleCreater(characteristicService), "POST", "/characteristics"}, r{handleGetter(characteristicService), "GET", "/characteristics/{ID:.+}"},