parent
299cd718b9
commit
62734899e2
6 changed files with 15 additions and 13 deletions
|
@ -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 {
|
||||
|
|
Reference in a new issue