本文整理匯總了Golang中github.com/eaciit/dbox.IQuery.Take方法的典型用法代碼示例。如果您正苦於以下問題:Golang IQuery.Take方法的具體用法?Golang IQuery.Take怎麽用?Golang IQuery.Take使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/eaciit/dbox.IQuery
的用法示例。
在下文中一共展示了IQuery.Take方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: parseQuery
func (d *DataSourceController) parseQuery(query dbox.IQuery, queryInfo toolkit.M) (dbox.IQuery, MetaSave) {
metaSave := MetaSave{}
if qFrom := queryInfo.Get("from", "").(string); qFrom != "" {
query = query.From(qFrom)
}
if qSelect := queryInfo.Get("select", "").(string); qSelect != "" {
if qSelect != "*" {
query = query.Select(strings.Split(qSelect, ",")...)
}
}
if qTakeRaw, qTakeOK := queryInfo["take"]; qTakeOK {
if qTake, ok := qTakeRaw.(float64); ok {
query = query.Take(int(qTake))
}
if qTake, ok := qTakeRaw.(int); ok {
query = query.Take(qTake)
}
}
if qSkipRaw, qSkipOK := queryInfo["skip"]; qSkipOK {
if qSkip, ok := qSkipRaw.(float64); ok {
query = query.Take(int(qSkip))
}
if qSkip, ok := qSkipRaw.(int); ok {
query = query.Take(qSkip)
}
}
if qOrder := queryInfo.Get("order", "").(string); qOrder != "" {
orderAll := map[string]string{}
err := json.Unmarshal([]byte(qOrder), &orderAll)
if err == nil {
orderString := []string{}
for key, val := range orderAll {
orderString = append(orderString, key)
orderString = append(orderString, val)
}
query = query.Order(orderString...)
}
}
if qInsert := queryInfo.Get("insert", "").(string); qInsert != "" {
if qInsert != "" {
metaSave.keyword = "insert"
metaSave.data = qInsert
query = query.Insert()
}
}
if qUpdate := queryInfo.Get("update", "").(string); qUpdate != "" {
if qUpdate != "" {
metaSave.keyword = "update"
metaSave.data = qUpdate
query = query.Update()
}
}
if _, qDeleteOK := queryInfo["delete"]; qDeleteOK {
metaSave.keyword = "delete"
query = query.Delete()
}
if qCommand := queryInfo.Get("command", "").(string); qCommand != "" {
command := map[string]interface{}{}
err := json.Unmarshal([]byte(qCommand), &command)
if err == nil {
for key, value := range command {
query = query.Command(key, value)
break
}
}
}
if qWhere := queryInfo.Get("where", "").(string); qWhere != "" {
whereAll := []map[string]interface{}{}
err := json.Unmarshal([]byte(qWhere), &whereAll)
if err == nil {
allFilter := []*dbox.Filter{}
for _, each := range whereAll {
where, _ := toolkit.ToM(each)
filter := d.filterParse(where)
if filter != nil {
allFilter = append(allFilter, filter)
}
}
query = query.Where(allFilter...)
}
}
return query, metaSave
}