If you are like me, you probably have not had much of a reason to use NoSQL but you have been interested in it. I recently decided to check out CouchDB. CouchDB is an Apache project that was created in 2005 by Damien Katz. CouchDB is interesting in that it stores your data with JSON documents and allows you to query via HTTP. This means that CouchDB provides it’s own web service.
For my tests, I used Iris Couch. Iris Couch is a free CouchDB hosting service. CouchDB offers a web-based administrative console called Futon. Once I created my Iris Couch account, I opened Futon. The first time you open Futon, you must secure your server. By default, out of the box, CouchDB give the whole world read/write permissions.
Once you set up an administrative account, you can look at creating your first Database.
Once you create your new database, you can start creating records (aka documents).
Rows do not have a predefined schema, so you can really put whatever you want. You can create each document with completely different field names, if you really wanted to.
For my example, I decided to store parts of my Resume.
With the skills section populated, the record listing looks like this:
So, how do you query this DB?
All records in the ‘resume_skills’ database
The record with the key ’1cbc470249c58bf6c40abd73f6001cc1′
Now, these aren’t the easiest ways to view the database. How can we make this nicer? We could create view.
Views in CouchDB are done purely with JavaScript. With the emit() function, the first parameter is the key and the second parameter is the value. In the above example, ‘Name’ is the key and the entire record is the value. You can save the view for later use.
So, now that we have a ‘all_skills’ view, how do we query it?
So, what if we only care about my ColdFusion experience?
This technology is cool for a number of reasons. The reason that immediately grabs me is that you don’t need to write any server-side code to create a JSON API. CouchDB does it for you.