CouchDB Deleting DataBase

Lets dive right in and Deleting your first CouchDB DataBase .Deleting a database is very simple - just type the command in your terminal window or command prompt.If you have to Delete a database then you must send an HTTP request to the server using the Delete method through the cURL utility.

Deleting a Database using cURL Utility

$ curl -X DELETE http://127.0.0.1:5984/database-name

Example :

. We will be working on the contacts database, so you have no need for the "couch-db" database.Command to delete "couch-db" database is :-

$ curl -X DELETE http://127.0.0.1:5984/couch-db
{
"ok" : true
}

When the database is Deleted, CouchDB responds with the following JSON object.{"0k": true}.The previous message basically means that the operation was successful and there was no error in CouchDB process of Deleting a couch-db database.
An error message will be generated when you attempt to delete the database which does not exist.

$ curl -X DELETE http://127.0.0.1:5984/couch-db

This time, the response you received should be an error message saying that the database does not exist.

{"error": "not found", "reason": "Missing"}



Verification :

Now that you have Deleted a database, let's ask CouchDB to specify which databases are currently available on the server.As you see there is not a database named "couch-db" in the list. So it is proved that the database has been deleted.

$ curl -X GET http://127.0.0.1:5984/_all_dbs
[ " letsfindcourse " , " contacts " ]



Visit :


Discussion



* You must be logged in to add comment.