func (c *C) Update(a iface.Filter, data map[string]interface{}) error { upd := map[string]interface{}{ "$set": data, } has_files := len(c.fileBiz) > 0 if has_files { ids, err := a.Ids() if err != nil { return err } err = c.moveFiles(a.Subject(), ids[0].String()) if err != nil { return err } upd["$addToSet"] = eachIfNeeded(fileNames(c.fileBiz)) } err := a.Update(upd) if err != nil { return err } if c.Hooks != nil { c.Hooks.Select("Updated").Fire(a) c.Hooks.Select(a.Subject() + "Updated").Fire(a) } return nil }
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) }
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) }
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) }
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.Hooks != nil { b.Hooks.Select("Updated").Fire(a) b.Hooks.Select(a.Subject() + "Updated").Fire(a) } return nil }
func (c *C) DeleteAllFiles(a iface.Filter, data map[string]interface{}) error { upd := map[string]interface{}{ "$unset": data["key"].(string), } return a.Update(upd) }