本文整理汇总了Golang中github.com/quintans/goSQL/db.Query.GetTable方法的典型用法代码示例。如果您正苦于以下问题:Golang Query.GetTable方法的具体用法?Golang Query.GetTable怎么用?Golang Query.GetTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/quintans/goSQL/db.Query
的用法示例。
在下文中一共展示了Query.GetTable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreateQueryProcessor
func (this *GenericTranslator) CreateQueryProcessor(query *db.Query) QueryProcessor {
proc := this.QueryProcessorFactory()
proc.Column(query)
if query.GetTable() != nil {
proc.From(query)
} else {
proc.FromSubQuery(query)
}
proc.Where(query)
// it is after the where clause because the joins can go to the where clause,
// and this way the restrictions over the driving table will be applied first
AppendJoins(query.GetJoins(), proc)
proc.Group(query)
proc.Having(query)
proc.Union(query)
proc.Order(query)
return proc
}
示例2: From
func (this *QueryBuilder) From(query *db.Query) {
table := query.GetTable()
alias := query.GetTableAlias()
this.fromPart.AddAsOne(this.translator.TableName(table), " ", alias)
}
示例3: QueryForPage
func QueryForPage(
query *db.Query,
criteria Criteria,
target interface{},
transformer func(in interface{}) interface{},
) (Page, error) {
max := criteria.PageSize
first := (criteria.Page - 1) * max
// for the first page the offset is zero
query.Skip(first)
if max > 0 {
query.Limit(max + 1)
}
var entities coll.Collection
var err error
var results []interface{}
if reflect.TypeOf(target).Kind() == reflect.Func {
results, err = query.ListInto(target)
} else if _, ok := target.(tk.Hasher); ok {
entities, err = query.ListFlatTreeOf(target)
} else {
entities, err = query.ListOf(target)
}
if err != nil {
return Page{}, err
}
if results == nil {
results = entities.Elements()
}
page := Page{}
size := int64(len(results))
if max > 0 && size > max {
page.Last = false
page.Results = results[:max]
} else {
page.Last = true
page.Results = results
}
// transform results
if transformer != nil {
for k, v := range page.Results {
page.Results[k] = transformer(v)
}
}
// count records
if criteria.CountRecords {
DB := query.GetDb()
cnt := DB.Query(query.GetTable())
cnt.Copy(query)
cnt.ColumnsReset()
cnt.CountAll()
cnt.OrdersReset()
var recs int64
_, err = cnt.SelectInto(&recs)
if err != nil {
return Page{}, err
}
page.Count = Int64(recs)
}
return page, nil
}