Refactor create handlers

Fixes #17.
This commit is contained in:
Matthew Dillon 2015-10-13 12:51:08 -07:00
parent 299cd718b9
commit 62734899e2
6 changed files with 15 additions and 13 deletions

View file

@ -3,11 +3,20 @@ package models
import "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/modl"
type base interface {
PreCreate(modl.SqlExecutor) error
PreInsert(modl.SqlExecutor) error
PreUpdate(modl.SqlExecutor) error
UpdateError() error
}
// Create will create a new DB record of a model.
func Create(b base) error {
if err := DBH.Insert(b); err != nil {
return nil
}
return nil
}
// Update runs a DB update on a model.
func Update(b base) error {
count, err := DBH.Update(b)
if err != nil {