CouchDB Updating Document

You can Update a document in CouchDB by sending an HTTP request to the server using PUT method through cURL utility.

Syntax

curl -X PUT http://127.0.0.1:5984/database_name/document_id/ -d 
'{ 
"field" : "value", "_rev" : "revision id" 
}'

Example :

The database with the "contacts" contains the document with ID johndoe. First you have to get the revision ID of the document which is to be updated. If you do not know _rev, you can find yourself in the document using the command below. Now after getting the revision ID, use _rev from the document to update the document. Now, we are updating the age of 25 to 30.

Find revision ID
$ curl -X GET http://127.0.0.1:5984/contacts/johndoe
{
"_id" : "johndoe",
"_rev" : "2-04d8eac1680d237ca25b68b36b8899d3 " ,
"age" : "25"
}
-----------------------------------------------------
-----------------------------------------------------
Updating Age
$ curl -X PUT http://127.0.0.1:5984/contacts/johndoe/ -d
' { " age " : " 30 " , " _rev " : " 1-1c2fae390fa5475d9b809301bbf3f25e " } '
{ " ok " : true , " id " : " johndoe " , " rev " : " 2-04d8eac1680d237ca25b68b36b8899d3 " }



Verification :

If you want to Verify the document, you can verify using GET request.

$ curl -X GET http://127.0.0.1:5984/contacts/johndoe
{
" _id " : " johndoe ",
" _rev " : " 2-04d8eac1680d237ca25b68b36b8899d3 " ,
" age " : " 30 "
}



Visit :


Discussion



* You must be logged in to add comment.

pHqghUme
555

pHqghUme
555

pHqghUme
555

pHqghUme
-1 OR 2+270-270-1=0+0+0+1 --

pHqghUme
-1 OR 3+270-270-1=0+0+0+1 --

pHqghUme
-1 OR 3*2<(0+5+270-270) --

pHqghUme
-1 OR 3*2>(0+5+270-270) --

pHqghUme
-1 OR 2+915-915-1=0+0+0+1

pHqghUme
-1 OR 3+915-915-1=0+0+0+1

pHqghUme
-1 OR 3*2<(0+5+915-915)

pHqghUme
-1 OR 3*2>(0+5+915-915)

pHqghUme
-1' OR 2+800-800-1=0+0+0+1 --

pHqghUme
-1' OR 3+800-800-1=0+0+0+1 --

pHqghUme
-1' OR 3*2<(0+5+800-800) --

pHqghUme
-1' OR 3*2>(0+5+800-800) --

pHqghUme
-1' OR 2+879-879-1=0+0+0+1 or 'qpBGQqJp'='

pHqghUme
-1' OR 3+879-879-1=0+0+0+1 or 'qpBGQqJp'='

pHqghUme
-1' OR 3*2<(0+5+879-879) or 'qpBGQqJp'='

pHqghUme
-1' OR 3*2>(0+5+879-879) or 'qpBGQqJp'='

pHqghUme
-1" OR 2+555-555-1=0+0+0+1 --

pHqghUme
-1" OR 3+555-555-1=0+0+0+1 --

pHqghUme
-1" OR 3*2<(0+5+555-555) --

pHqghUme
-1" OR 3*2>(0+5+555-555) --

pHqghUme
if(now()=sysdate(),sleep(15),0)

pHqghUme
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z

pHqghUme
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z

pHqghUme
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

pHqghUme
-1; waitfor delay '0:0:15' --

pHqghUme
-1); waitfor delay '0:0:15' --

pHqghUme
1 waitfor delay '0:0:15' --

pHqghUme
Df9cp2k4'; waitfor delay '0:0:15' --

pHqghUme
-5 OR 332=(SELECT 332 FROM PG_SLEEP(15))--

pHqghUme
-5) OR 764=(SELECT 764 FROM PG_SLEEP(15))--

pHqghUme
-1)) OR 985=(SELECT 985 FROM PG_SLEEP(15))--

pHqghUme
sDxToO0X' OR 436=(SELECT 436 FROM PG_SLEEP(15))--

pHqghUme
BihJ9YfI') OR 94=(SELECT 94 FROM PG_SLEEP(15))--

pHqghUme
iYw0FVKr')) OR 578=(SELECT 578 FROM PG_SLEEP(15))--

pHqghUme
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

pHqghUme
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

pHqghUme
1'"

pHqghUme

pHqghUme
@@kMVIe

pHqghUme
555

pHqghUme
555

pHqghUme
555