Mar
9
Two line solution to drop all data from CouchDB
Today was my first day when I actually had to use CouchDB on a real project. The problem I stumbled upon while developing is that there is no way to just drop all that data in a databse from the beautiful web interface that CouchDB has.
After about 15 minutes of fiddling around with the _deleted attribute, I came to a dead simple solution.
namespace :couch do
desc "Delete and create database"
task :wipe do
system('curl -X DELETE http://localhost:5984/dev')
system('curl -X PUT http://localhost:5984/dev')
end
end
There is definitely a better way to do this, but it’s my first day with CouchDB. One thing I definitely like about the REST API is how simple it is to do something like this. All it takes is just little command line tinkering.