Beispiel #1
0
// Find revisions.
//
// @return map[string]interface{}, error
func (this *Document) FindRevisions() (map[string]interface{}, error) {
	data, err := this.Find(util.ParamList("revs", true))
	if err != nil {
		return nil, err
	}

	ret := util.Map()
	if data["_revisions"] != nil {
		ret["start"] = util.DigInt("_revisions.start", data)
		ret["ids"] = util.DigSliceString("_revisions.ids", data)
	}

	return ret, nil
}
Beispiel #2
0
// Purge
//
// @param  object map[string]interface{}
// @return map[string]interface{}, error
func (this *Database) Purge(object map[string]interface{}) (map[string]interface{}, error) {
	data, err := this.Client.Post(this.Name+"/_purge", nil, object, nil).GetBodyData(nil)
	if err != nil {
		return nil, err
	}

	ret := util.Map()
	ret["purge_seq"] = util.DigInt("purge_seq", data)
	ret["purged"] = util.Map()
	// fill purged revs
	for id, revs := range data.(map[string]interface{})["purged"].(map[string]interface{}) {
		ret["purged"].(map[string]interface{})[id] = revs
	}

	return ret, nil
}