My various small term and long-term projects need database. As of now I have used various kinds of RDBMS like Postgres,SQLite, NoSQLs like Mongo and Redis. All these four are great and have made me really productive. All four databases are open source and they cover all my requirements as of now. But recently I was in need of database with simple restful api, that can take or spit JSON. My immediate response was Eve+Mongo or sandman+rdbms . Both of them work well. I have used them before. But this time I needed much simpler tool, that would store data, give me restful API and easy interface to maintain. And that’s how I ended up using CouchDB.
The projects I am talking are my personal GPS logger which logs the locations while I am travelling. Couple of small IoT devices, a weather station, data I collect as part of quantified self etc. They are not very complex in terms of data structure. But they need a flexible, stable and simple system.
A simple Backend-as-a-Service platform is what I wanted. Something that was open source and can be hosted by me easily. So Firebase and other similar services got excluded easily. Open Source BaaS has many choices Meteor , Hook , Hoodie , etc. They are all good choices. Some of them are even built on the top of CouchDB. But I choose CouchDB over others for a bunch of reasons.
Futuon UI. Screen shot by couchdb.org
- NoSQL – It’s a simple versioned document store. You put the JSON and You get the JSON back. Just like in any other NoSQL its schema-less.
- Restful API You access database through restful API. Thats the primary way to get access to the database. Since its restful, you can interact with the database direct from browser or mobile.
- Replication synchronizes two copies of the same database and works really well.
- Simple JSONP is part of CouchDB. If you want to just access the data. You could use this.
- Futon UI is a native web-based interface built into CouchDB. Its like PHPMyAdmin but much better UI and it comes by default.
- Media Attachments can be stored on CouchDB. Even though it’s not advised to use it as a file storage, the fact that it can store BLOBs makes it useful in certain situations.
- CouchDB has built-in support for Auth and Sessions . You can use the same RESTFUL api to create a web-session. Basically POST username and password to _session and you will receive a cookie. You can use this cookie for all the future transactions. You can also use simple https://username:email@example.com/mydatabase if that suits your taste.
- Users can write Validation functions on couchdb. This can be used to validate the documents while inserting or updating.
- All the views are MapReduce . You have to write MapReduce to query the database.
- All these features are one single installation. And everything happens over http (i prefer https). It makes the system simple, secure and stable .
In the next set of blog posts I will write about my use-cases and projects. In the mean time let me know what you think.