Tag: couchdb

MongoDB and the rest of NoSQL solutions

Posted by – August 8, 2009

In the last weeks I have been evaluating two NoSQL solutions available in the market, MongoDB and CouchDB, each solution has very interesting features, but besides of its features we must consider how much easy to use each one is, right?

Let’s talk a little about CouchDB first, CouchDB is a document-oriented solution written in Erlang language, with CouchDB you can easily persist documents in JSON format it also has a very powerful RESTful interface from where you can retrieve database information and persist/query documents.

But how to perform basic operations on CouchDB like persist or query data? It’s simple, you just need to know how to use its RESTful interface, the example below shows how much easy is persist data in CouchDB with help of curl tool:

curl -X PUT -d '{"name": "Rogerio Araujo", "address": "Estrada dos Bandeirantes", "city": "Rio de Janeiro", "state": "RJ", "country": "Brazil" }' ""

The command above will create the following JSON document on database:

{ "_id": "user3", "_rev": "3771096703", "name": "Rogerio Araujo", "address": "Estrada dos Bandeirantes", "city": "Rio de Janeiro", "state": "RJ", "country": "Brazil" }

Once we have few documents stored on CouchDB we need to create a view used to help on query data, to do it, you must write the following javascript function and store it as a document on database:

function(doc) {
     emit(doc.name, doc);