[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 (
|
import (
|
||||||
"github.com/yaoapp/gou"
|
"github.com/yaoapp/gou"
|
||||||
|
"github.com/yaoapp/gou/query"
|
||||||
dsl "github.com/yaoapp/gou/query/gou"
|
dsl "github.com/yaoapp/gou/query/gou"
|
||||||
"github.com/yaoapp/kun/log"
|
"github.com/yaoapp/kun/log"
|
||||||
"github.com/yaoapp/xun/capsule"
|
"github.com/yaoapp/xun/capsule"
|
||||||
|
|
@ -10,21 +11,21 @@ import (
|
||||||
|
|
||||||
// Load 加载查询引擎
|
// Load 加载查询引擎
|
||||||
func Load(cfg config.Config) {
|
func Load(cfg config.Config) {
|
||||||
XiangQuery()
|
DefaultQuery()
|
||||||
}
|
}
|
||||||
|
|
||||||
// XiangQuery 注册应用引擎象 xiang
|
// DefaultQuery register the default engine
|
||||||
func XiangQuery() {
|
func DefaultQuery() {
|
||||||
gou.RegisterEngine("xiang", &dsl.Query{
|
query.Register("default", &dsl.Query{
|
||||||
Query: capsule.Query(),
|
Query: capsule.Query(),
|
||||||
GetTableName: func(s string) string {
|
GetTableName: func(s string) string {
|
||||||
if mod, has := gou.Models[s]; has {
|
if mod, has := gou.Models[s]; has {
|
||||||
return mod.MetaData.Table.Name
|
return mod.MetaData.Table.Name
|
||||||
}
|
}
|
||||||
// exception.New("%s 数据模型尚未加载", 404).Throw()
|
|
||||||
log.Error("%s model does not load", s)
|
log.Error("%s model does not load", s)
|
||||||
return s
|
return s
|
||||||
},
|
},
|
||||||
AESKey: config.Conf.DB.AESKey,
|
AESKey: config.Conf.DB.AESKey,
|
||||||
})
|
})
|
||||||
|
query.Alias("default", "xiang")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue