Beispiel #1
0
// Find attachments
//
// @param  attEncInfo bool
// @param  attsSince []string
// return  []map[string]interface{}, error
func (this *Document) FindAttachments(
	attEncInfo bool, attsSince []string) ([]map[string]interface{}, error) {
	query := util.Map()
	query["attachments"] = true
	query["att_encoding_info"] = attEncInfo

	if attsSince != nil {
		attsSinceArray := util.MapSliceString(attsSince)
		for _, attsSinceValue := range attsSince {
			attsSinceArray = append(attsSinceArray, util.QuoteEncode(attsSinceValue))
		}
	}

	data, err := this.Find(query)
	if err != nil {
		return nil, err
	}

	ret := util.MapList(nil)
	if data["_attachments"] != nil {
		for _, attc := range data["_attachments"].(map[string]interface{}) {
			ret = append(ret, attc.(map[string]interface{}))
		}
	}

	return ret, nil
}
Beispiel #2
0
// Get all databases.
//
// @return []string, error
func (this *Server) GetAllDatabases() ([]string, error) {
	data, err := this.Client.Get("/_all_dbs", nil, nil).GetBodyData(nil)
	if err != nil {
		return nil, err
	}

	ret := util.MapSliceString(data)
	for i, db := range data.([]interface{}) {
		ret[i] = db.(string)
	}

	return ret, nil
}
Beispiel #3
0
// Get UUIDs.
//
// @return []string, error
func (this *Server) GetUuids(count int) ([]string, error) {
	query := util.ParamList(
		"count", count,
	)
	data, err := this.Client.Get("/_uuids", query, nil).GetBodyData(nil)
	if err != nil {
		return nil, err
	}

	ret := util.MapSliceString(count)
	for i, uuid := range data.(map[string]interface{})["uuids"].([]interface{}) {
		ret[i] = uuid.(string)
	}

	return ret, nil
}