本文整理匯總了Golang中github.com/opesun/chill/frame/interfaces.Filter.Subject方法的典型用法代碼示例。如果您正苦於以下問題:Golang Filter.Subject方法的具體用法?Golang Filter.Subject怎麽用?Golang Filter.Subject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/opesun/chill/frame/interfaces.Filter
的用法示例。
在下文中一共展示了Filter.Subject方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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)
}
示例2: 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
}
示例3: 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)
}
示例4: 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
}
示例5: 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
}
示例6: 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
}
示例7: 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
}