I’ve spent quite a lot of time experimenting with document databases at the moment, almost exclusively RavenDb of late. We’re currently looking at sweeping architecture changes at work, and unfortunately it doesn’t look like Raven is going to be suitable (nothing to do with the product, which is excellent, just a target audience with a specific ambivalence to Windows server exclusive products). Knowing that a lot of Ravens design decisions were based around using CouchDb, and knowing that CouchDb might be a better fit for the scenario I have in mind, I set out to see how easy Couch is to use on Windows.
Short answer? Very very easy, so here’s a few quick steps for someone that wants to get up and running quickly.
First, go grab a copy of your platform-specific installer from CouchBase and install it. This is a 2-3 click process, and as the installer exits your browser pops up into “Futon” the Couch web UI.
Then go to https://github.com/foretagsplatsen/Divan , clone / download the Divan source code and build it. Divan is a handy open source project aimed at wrapping the Couch API (which is RESTful, so if you want to roll your own client library feel free). Divan is quite bare to the metal and relies on Json.Net for de/serializing documents.
Launch Visual Studio and new up a project of your choice. I’ve chucked together a few utility classes while experimenting to deal with persistence in order to get a syntax that looks like this:
Which I’m pretty happy with as it seems very usable and maps pretty simply from the underlying Json documents.
I have a base class and an interface at the bottom of the object graph that look like this
and two little repository classes that look like this:
They’re obviously not entirely fleshed out, and the Divan project obviously encapsulates more of Couches functionality than those two methods alone.
When you execute the code snippet above (which for the sake of this example was just in a random ASP.NET MVC Controller’s Get method) you’ll see a new database called “myfirstdatabase” created in Futon with your newly created document inside it.
This is obviously just scratching at the surface, but I’ve been exceptionally pleased at how easy it is to get a File –> New Project up and running using readily available tools.