Deleting a Document using cURL Utility
You can erase a record in CouchDB by sending a HTTP solicitation to the worker utilizing DELETE strategy through cURL utility. Following is the language structure to erase a record.
curl -X DELETE http : // 127.0.0.1:5984 / database name/database id?_rev id
Utilizing −X, we can determine a custom solicitation technique for HTTP we are utilizing, while at the same time speaking with the HTTP worker. For this situation, we are utilizing Delete technique. To erase an information base/database_name/database_id/isn't sufficient. You need to pass the new update id through the url. To make reference to traits of any information structure "?" is utilized.
Model
Assume there is a report in data set named my_database with archive id 001. To erase this report, you need to get the fire up id of the record. Get the archive information as demonstrated beneath.
$ curl -X GET http://127.0.0.1:5984/my_database/001
{
" _id " : " 001 ",
" _rev " : " 2-04d8eac1680d237ca25b68b36b8899d3 " ,
" age " : " 23 "
}
Presently determine the amendment id of the archive to be erased, id of the record, and information base name the report has a place with, as demonstrated underneath −
$ curl -X DELETE http://127.0.0.1:5984/my_database/001?rev=1-
3fcc78daac7a90803f0a5e383f4f1e1e
{"ok":true,"id":"001","rev":"2-3a561d56de1ce3305d693bd15630bf96"}
Check
To confirm whether the archive is erased, attempt to bring the record by utilizing the GET technique. Since you are bringing an erased archive, this will give you a blunder message as demonstrated underneath −
$ curl -X GET http://127.0.0.1:5984/my_database/001
{"error":"not_found","reason":"deleted"}
Erasing a Document utilizing Futon
Most importantly, check the reports in the information base. Following is the preview of the data set named tutorials_point.
Here you can notice, the information base comprises of three records. To erase any of the records state 003, do the accompanying −
- Snap on the archive, you will get a page demonstrating the substance of chose record as field-esteem sets.
- This page likewise contains four choices specifically Save Document, Add Field, Upload Attachment, Delete Document.
- Snap on Delete Document choice.
- You will get a discourse box saying "Are you certain you need to erase this record?" Click on erase, to erase the archive.