本文整理汇总了Golang中github.com/opesun/chill/frame/interfaces.Filter类的典型用法代码示例。如果您正苦于以下问题:Golang Filter类的具体用法?Golang Filter怎么用?Golang Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: RegenerateFulltext
func (c *C) RegenerateFulltext(a iface.Filter) error {
cb := func(doc map[string]interface{}, g iface.Grabbed) error {
upd := c.updateFromDoc(doc)
return g.Update(upd)
}
return a.Iterate(cb)
}
开发者ID:Laller,项目名称:chill,代码行数:7,代码来源:fulltext.go
示例2: New
func (c *C) New(a iface.Filter) ([]map[string]interface{}, error) {
scheme, err := c.getScheme(a.Subject(), "Insert")
if err != nil {
return nil, err
}
return convert.SchemeToFields(scheme, nil)
}
开发者ID:Laller,项目名称:chill,代码行数:7,代码来源:file.go
示例3: UpdateAll
func (b *Basics) UpdateAll(a iface.Filter, data map[string]interface{}) error {
upd := map[string]interface{}{
"$set": data,
}
_, err := a.UpdateAll(upd)
return err
}
开发者ID:Laller,项目名称:chill,代码行数:7,代码来源:basics.go
示例4: Insert
func (c *C) Insert(a iface.Filter, data map[string]interface{}) error {
m, err := c.decrypt(data)
if err != nil {
return err
}
m["created"] = time.Now().UnixNano() // Should include user too maybe.
return a.Insert(m)
}
开发者ID:Laller,项目名称:chill,代码行数:8,代码来源:jsonedit.go
示例5: Update
func (c *C) Update(a iface.Filter, data map[string]interface{}) error {
m, err := c.decrypt(data)
if err != nil {
return err
}
m["modified"] = time.Now().UnixNano()
return a.Update(m)
}
开发者ID:Laller,项目名称:chill,代码行数:8,代码来源:jsonedit.go
示例6: DeleteFile
func (c *C) DeleteFile(a iface.Filter, data map[string]interface{}) error {
upd := map[string]interface{}{
"$pull": map[string]interface{}{
data["key"].(string): data["file"],
},
}
return a.Update(upd)
}
开发者ID:Laller,项目名称:chill,代码行数:8,代码来源:file.go
示例7: SaveFulltext
func (c *C) SaveFulltext(a iface.Filter) error {
doc, err := a.FindOne()
if err != nil {
return err
}
upd := c.updateFromDoc(doc)
return a.Update(upd)
}
开发者ID:Laller,项目名称:chill,代码行数:8,代码来源:fulltext.go
示例8: FindUser
// Finds a user by id.
func FindUser(a iface.Filter, id bson.ObjectId) (map[string]interface{}, error) {
q := m{"_id": id}
v, err := a.AddQuery(q).FindOne()
if err != nil {
return nil, err
}
delete(v, "password")
return v, nil
}
开发者ID:Laller,项目名称:chill,代码行数:10,代码来源:user_model.go
示例9: namePass
// Finds he user by name password equality.
func namePass(a iface.Filter, name, encoded_pass string) (map[string]interface{}, error) {
q := bson.M{
"name": name,
"password": encoded_pass,
}
doc, err := a.AddQuery(q).FindOne()
if err != nil {
return nil, err
}
return convert.Clean(doc).(map[string]interface{}), nil
}
开发者ID:Laller,项目名称:chill,代码行数:12,代码来源:user_model.go
示例10: Edit
func (c *C) Edit(a iface.Filter) ([]map[string]interface{}, error) {
doc, err := a.FindOne()
if err != nil {
return nil, err
}
scheme, err := c.getScheme(a.Subject(), "Update")
if err != nil {
return nil, err
}
return convert.SchemeToFields(scheme, doc)
}
开发者ID:Laller,项目名称:chill,代码行数:11,代码来源:file.go
示例11: NameAvailable
// Returns true if the username is still available.
func NameAvailable(a iface.Filter, name string) (bool, error) {
q := bson.M{"slug": slugify.S(name)}
users, err := a.AddQuery(q).Find()
if err != nil {
return false, err
}
if len(users) > 0 {
return false, nil
}
return true, nil
}
开发者ID:Laller,项目名称:chill,代码行数:12,代码来源:user_model.go
示例12: RegisterUser
func RegisterUser(a iface.Filter, user map[string]interface{}) (bson.ObjectId, error) {
user["password"] = hashPass(user["password"].(string))
if _, has := user["level"]; !has {
user["level"] = 100
}
user_id := bson.NewObjectId()
user["_id"] = user_id
err := a.Insert(user)
if err != nil {
return "", fmt.Errorf("Name is not unique.")
}
return user_id, nil
}
开发者ID:Laller,项目名称:chill,代码行数:13,代码来源:user_model.go
示例13: Update
func (c *C) Update(a iface.Filter, data map[string]interface{}) error {
files_map, has := data["_files"].(map[string]interface{})
upd := map[string]interface{}{
"$set": data,
}
if has {
ids, err := a.Ids()
if err != nil {
return err
}
err = c.moveFiles(a.Subject(), ids[0].Hex(), files_map)
if err != nil {
return err
}
delete(data, "_files")
upd["$addToSet"] = eachIfNeeded(fileheadersToFilenames(files_map))
}
err := a.Update(upd)
if err != nil {
return err
}
if c.Ev != nil {
c.Ev.Fire("Updated", a)
c.Ev.Fire(a.Subject()+"Updated", a)
}
return nil
}
开发者ID:Laller,项目名称:chill,代码行数:27,代码来源:file.go
示例14: Edit
func (c *C) Edit(a iface.Filter) (string, error) {
doc, err := a.FindOne()
if err != nil {
return "", err
}
for _, v := range ignore {
delete(doc, v)
}
marsh, err := json.MarshalIndent(doc, "", "\t")
if err != nil {
return "", err
}
return string(marsh), nil
}
开发者ID:Laller,项目名称:chill,代码行数:14,代码来源:jsonedit.go
示例15: Update
func (b *Basics) Update(a iface.Filter, data map[string]interface{}) error {
upd := map[string]interface{}{
"$set": data,
}
err := a.Update(upd)
if err != nil {
return err
}
if b.Ev != nil {
b.Ev.Fire("Updated", a)
b.Ev.Fire(a.Subject()+"Updated", a)
}
return nil
}
开发者ID:Laller,项目名称:chill,代码行数:14,代码来源:basics.go
示例16: 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
}
开发者ID:Laller,项目名称:chill,代码行数:14,代码来源:users.go
示例17: Reduce
func (f *Filter) Reduce(a ...iface.Filter) (iface.Filter, error) {
l := len(a)
if l == 0 {
return &Filter{}, fmt.Errorf("Nothing to reduce.")
}
var prev iface.Filter
prev = f
for _, v := range a {
ids, err := prev.Ids()
if err != nil {
return &Filter{}, err
}
v.AddParents("_"+prev.Subject(), ids)
prev = v
}
return prev, nil
}
开发者ID:Laller,项目名称:chill,代码行数:17,代码来源:filter.go
示例18: Insert
func (c *C) Insert(a iface.Filter, data map[string]interface{}) (bson.ObjectId, error) {
files_map, has_files := data["_files"].(map[string]interface{})
if has_files {
delete(data, "_files")
merge(data, fileheadersToFilenames(files_map))
}
id, err := c.Basics.Insert(a, data)
if err != nil {
return id, err
}
if has_files {
err := c.moveFiles(a.Subject(), id.Hex(), files_map)
if err != nil {
return "", err
}
}
return id, nil
}
开发者ID:Laller,项目名称:chill,代码行数:18,代码来源:file.go
示例19: Get
func (b *Basics) Get(a iface.Filter) ([]interface{}, *QueryInfo, error) {
list, err := a.Find()
if err != nil {
return nil, nil, err
}
count, err := a.Count()
if err != nil {
return nil, nil, err
}
return list, &QueryInfo{
count, a.Modifiers().Skip(),
a.Modifiers().Limit(),
a.Modifiers().Sort(),
}, nil
}
开发者ID:Laller,项目名称:chill,代码行数:15,代码来源:basics.go
示例20: Insert
func (b *Basics) Insert(a iface.Filter, data map[string]interface{}) (bson.ObjectId, error) {
id := bson.NewObjectId()
data["_id"] = id
err := a.Insert(data)
if err != nil {
return "", err
}
if b.Ev != nil {
q := map[string]interface{}{
"_id": id,
}
filt := a.Clone().AddQuery(q)
b.Ev.Fire("Inserted", filt)
b.Ev.Fire(a.Subject()+"Inserted", filt)
}
return id, nil
}
开发者ID:Laller,项目名称:chill,代码行数:17,代码来源:basics.go
注:本文中的github.com/opesun/chill/frame/interfaces.Filter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论