Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const PkgName = "auxo.db.gsd.proxy"
Variables ¶
View Source
var (
Default = New(nil)
)
Functions ¶
Types ¶
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
func (*Proxy) Apply ¶
Apply generate data access methods according to fields of i.
Example ¶
package main import ( "github.com/cuigh/auxo/db/gsd/proxy" ) func main() { type User struct { ID int32 `gsd:",auto"` Name string } type UserDao struct { Get func(id int32) (*User, error) `gsd:"find,cache:user.load"` Load func(u *User) error `gsd:"load,cache:user.load"` Remove func(u *User) error `gsd:"remove"` Create func(u *User) error `gsd:"create"` Update func(u *User) error `gsd:"modify"` } dao := &UserDao{} proxy.Apply("test", dao) user, err := dao.Get(1) if err != nil { panic(err) } err = dao.Load(user) if err != nil { panic(err) } user = &User{ID: 2, Name: "noname"} err = dao.Create(user) if err != nil { panic(err) } user.Name = "noname" err = dao.Update(user) if err != nil { panic(err) } err = dao.Remove(user) if err != nil { panic(err) } }
Output:
Click to show internal directories.
Click to hide internal directories.