Working with local documents in CouchDB
$ http :5984/koi/_local/020
{
" error" : " not_found" ,
" reason" : " missing"
}
$ http put :5984/koi/_local/020 number=12.71
{
" id" : " _local/020" ,
" ok" : true,
" rev" : " 0-1"
}
$ http :5984/koi/_local/020
{
" _id" : " _local/020" ,
" _rev" : " 0-1" ,
" number" : " 12.71"
}
Update document (check out, no query param "rev" needed)
http put :5984/koi/_local/020 number=12.71 local:=true
{
" id" : " _local/020" ,
" ok" : true,
" rev" : " 0-1"
}
Re-read it (notice the same _rev)
$ http :5984/koi/_local/020
{
" _id" : " _local/020" ,
" _rev" : " 0-1" ,
" local" : true,
" number" : " 12.71"
}
Copy to non-local document
$ http copy :5984/koi/_local/020 Destination:021
{
" id" : " 021" ,
" ok" : true,
" rev" : " 1-625185140e3e3e8edb88ce77e0357d15"
}
$ http :5984/koi/021
{
" _id" : " 021" ,
" _rev" : " 1-625185140e3e3e8edb88ce77e0357d15" ,
" local" : true,
" number" : " 12.71"
}
$ http copy :5984/koi/_local/020 Destination:_local/021
{
" id" : " _local/021" ,
" ok" : true,
" rev" : " 0-1"
}
$ http :5984/koi/_local/021
{
" _id" : " _local/021" ,
" _rev" : " 0-1" ,
" local" : true,
" number" : " 12.71"
}
Delete local document (check out _rev)
$ http delete :5984/koi/_local/020
{
" id" : " _local/020" ,
" ok" : true,
" rev" : " 0-0"
}
Confirm it is deleted for real
$ http :5984/koi/_local/020
{
" error" : " not_found" ,
" reason" : " missing"
}
$ http :5984/koi/_local/020 rev==0-1
{
" error" : " not_found" ,
" reason" : " missing"
}