[add] Javascript Query object
This commit is contained in:
parent
94a2a6d3c4
commit
5548bc59dd
1 changed files with 6 additions and 5 deletions
|
|
@ -2,6 +2,7 @@ package query
|
|||
|
||||
import (
|
||||
"github.com/yaoapp/gou"
|
||||
"github.com/yaoapp/gou/query"
|
||||
dsl "github.com/yaoapp/gou/query/gou"
|
||||
"github.com/yaoapp/kun/log"
|
||||
"github.com/yaoapp/xun/capsule"
|
||||
|
|
@ -10,21 +11,21 @@ import (
|
|||
|
||||
// Load 加载查询引擎
|
||||
func Load(cfg config.Config) {
|
||||
XiangQuery()
|
||||
DefaultQuery()
|
||||
}
|
||||
|
||||
// XiangQuery 注册应用引擎象 xiang
|
||||
func XiangQuery() {
|
||||
gou.RegisterEngine("xiang", &dsl.Query{
|
||||
// DefaultQuery register the default engine
|
||||
func DefaultQuery() {
|
||||
query.Register("default", &dsl.Query{
|
||||
Query: capsule.Query(),
|
||||
GetTableName: func(s string) string {
|
||||
if mod, has := gou.Models[s]; has {
|
||||
return mod.MetaData.Table.Name
|
||||
}
|
||||
// exception.New("%s 数据模型尚未加载", 404).Throw()
|
||||
log.Error("%s model does not load", s)
|
||||
return s
|
||||
},
|
||||
AESKey: config.Conf.DB.AESKey,
|
||||
})
|
||||
query.Alias("default", "xiang")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue