func (gom *Gomdise) SaveWithKey(arg interface{}, key string) (err error) { defer func() { err = errorRecover() }() tpl := tpl.TCSave.GetTemplate(reflect.TypeOf(arg)) tran := trans.NewTransaction(gom.pool) v := reflect.ValueOf(arg) tpl.Engrave(&tran.Actions, key, v) tran.Exec() return nil }
func (gom *Gomdise) Find(key string, dest interface{}) (err error) { defer func() { err = errorRecover() }() tpl := tpl.TCFind.GetTemplate(reflect.TypeOf(dest)) tran := trans.NewTransaction(gom.pool) tpl.Engrave(&tran.Actions, key) root := tran.Actions[0] tran.Exec() mdl.Decode(root, dest) return nil }
func (gom *Gomdise) Save(arg interface{}) (key string, err error) { defer func() { err = errorRecover() if err != nil { key = "" } }() tpl := tpl.TCSave.GetTemplate(reflect.TypeOf(arg)) tran := trans.NewTransaction(gom.pool) v := reflect.ValueOf(arg) key = mdl.NewKey(v) tpl.Engrave(&tran.Actions, key, v) tran.Exec() return key, nil }