func export support
支持快捷函数导出。
This commit is contained in:
@@ -4,26 +4,24 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/xxjwxc/gormt/data/view/genfunc/model"
|
||||
|
||||
"github.com/xxjwxc/public/mysqldb"
|
||||
)
|
||||
|
||||
func TestFunc(t *testing.T) {
|
||||
orm := mysqldb.OnInitDBOrm("root:qwer@tcp(127.0.0.1:3306)/matrix?charset=utf8&parseTime=True&loc=Local")
|
||||
defer orm.OnDestoryDB()
|
||||
mgr := model.OrganMgr(orm.DB)
|
||||
mgr.IsRelated(true) // 设置允许加载外键
|
||||
res, err := mgr.GetFromUserID(2) // 通过列获取
|
||||
fmt.Println(res, err)
|
||||
|
||||
mgr := ExampleMgr(orm.DB)
|
||||
obj, err := mgr.GetFromID(1)
|
||||
fmt.Println(obj, err)
|
||||
|
||||
obj1, err := mgr.GetByPrimaryKey(1)
|
||||
obj1, err := mgr.GetByOptions(mgr.WithID(1), mgr.WithUserID(1)) // 批量获取
|
||||
fmt.Println(obj1, err)
|
||||
|
||||
obj2, err := mgr.GetByPrimaryKeys([]int64{1, 2})
|
||||
obj2, err := mgr.GetByOption(mgr.WithID(1), mgr.WithUserID(1)) // 多条件获取一条
|
||||
fmt.Println(obj2, err)
|
||||
|
||||
obj3, err := mgr.GetByOptions(mgr.WithID(1), mgr.WithUserID(1))
|
||||
fmt.Println(obj3, err)
|
||||
|
||||
obj4, err := mgr.GetByOption(mgr.WithID(1), mgr.WithUserID(1))
|
||||
fmt.Println(obj4, err)
|
||||
// 复合键获取
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user