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 }
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 (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 (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 }
func (c *C) DeleteAllFiles(a iface.Filter, data map[string]interface{}) error { upd := map[string]interface{}{ "$unset": data["key"].(string), // We don't care about the files themselves. } return a.Update(upd) }