
Untitled
By: a guest on
May 6th, 2012 | syntax:
None | size: 0.97 KB | hits: 15 | expires: Never
########### CouchDB api-bash ###########
###### type less, relax more ###########
function iris () {
export irdb="http://tzk.iriscouch.com/$1"
}
function here () {
export loc="http://127.0.0.1:5984/$1"
}
## revision/2 : base doc
function revision () {
return curl -s -n -X GET "$1/$2" | cut -d, -f2 | cut -d\" -f4
}
## delete/2 base doc
function delete () {
local version=revision $1 $2
local resource="$1/$2"
curl -s -n -H "Content-Type: application/json" \
-X DELETE "$1/$2?rev=$version"
}
## list/2 base includep (if non-nil, true)
function list () {
if [ $2 == "" ]; then
include=""
else
include="&include_docs=true"
fi
curl -s -n -X GET "$1?_all_docs$include"
}
## replicate/3 source target continuous
function replicate () {
if [ $3 == "" ]; then
continuous=""
else
continuous=",\"continuous\":true"
fi
curl -X POST http://127.0.0.1:5984/_replicate \
-d "{\"source\":\"$1\",\"target\":"$2",$continuous}"
}