Maladroit Elusive Transaction Hub
A wrapper around upper.io/db to ease some repetitive tasks.
Working with upper.io/db sometimes becomes a little bit repetitive, so METH is an attempt to minimize the scaffolding needed in some basic tasks [fetching by id, by certain conditions].
go get github.com/worg/meth
Any type must implement Persistent interface and return an initalized and valid db.Collection in order to use METH functions.
package person
import (
"upper.io/db""upper.io/db/some_driver"
)
typePersonstruct {
IDint`db:"id"`Namestring`db:"name"`Addressstring`db:"address"`
}
var (
collection db.Collection
)
funcinit() {
//init DB and set collection
}
func (p*Person) Collection() db.Collection {
returncollection
}
func (p*Person) ById(idint) {
iferr:=meth.One(&p); err:=nil {
// handle err
}
// by this point p should've been filled with db data
}