本文整理匯總了Golang中github.com/opesun/nocrud/frame/interfaces.Filter.AddQuery方法的典型用法代碼示例。如果您正苦於以下問題:Golang Filter.AddQuery方法的具體用法?Golang Filter.AddQuery怎麽用?Golang Filter.AddQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/opesun/nocrud/frame/interfaces.Filter
的用法示例。
在下文中一共展示了Filter.AddQuery方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: othersAlreadyTook
func (e *Entries) othersAlreadyTook(a iface.Filter, from, to int64) error {
entryQ := map[string]interface{}{
"$or": []interface{}{
map[string]interface{}{
"from": map[string]interface{}{
"$gt": from,
"$lt": to,
},
},
map[string]interface{}{
"to": map[string]interface{}{
"$gt": from,
"$lt": to,
},
},
},
}
a.AddQuery(entryQ)
eC, err := a.Count()
if err != nil {
return err
}
if eC > 0 {
return fmt.Errorf("That time is already taken.")
}
return nil
}
示例2: _new
func _new(db iface.Db, f iface.Filter, hooks iface.Hooks, client iface.Client) (*User, error) {
uidI, err := client.GetDecrypted("user")
if err != nil {
return nil, err
}
id, err := db.ToId(uidI.(string))
if err != nil {
return nil, err
}
q := map[string]interface{}{
"_id": id,
}
f.AddQuery(q)
userDoc, err := f.SelectOne()
if err != nil {
return nil, err
}
var langs []string
if langz, ok := userDoc.Data()["languages"].([]interface{}); ok {
for _, v := range langz {
langs = append(langs, v.(string))
}
} else if client.Languages() != nil {
langs = client.Languages()
} else {
langs = []string{"en"}
}
return &User{
userDoc,
numcon.IntP(userDoc.Data()["level"]),
langs,
}, nil
}
示例3: FindLogin
func FindLogin(a iface.Filter, name, password string) (iface.Document, error) {
encoded_pass := hashPass(password)
q := map[string]interface{}{
"name": name,
"password": encoded_pass,
}
return a.AddQuery(q).SelectOne()
}
示例4: TopModFilter
// This way professionals will only see entries posted for them,
// and users will only see entries posted by them.
// However, a professional will not be able to act as a user: he wont see entries posted by him, posted for other professionals.
func (e *Entries) TopModFilter(a iface.Filter) {
if e.userIsProfessional {
a.AddQuery(map[string]interface{}{
"forProfessional": e.userId,
})
} else {
a.AddQuery(map[string]interface{}{
"createdBy": e.userId,
})
}
}
示例5: hasAdmin
func hasAdmin(f iface.Filter) error {
q := map[string]interface{}{
"level": 300,
}
f.AddQuery(q)
c, err := f.Count()
if err != nil {
return err
}
if c > 0 {
return fmt.Errorf("Site already has an admin.")
}
return nil
}