Mikael's blog

A developers seventh time trying to maintain a blog

Tag #couchdb

The Development Environment Enigma | March 3, 2012 at 10:22

As you might have noticed, there hasn't been much work done on the blog these last few months. It kind of boils down to complexity. ## The Old Setup When I started building this blog my main workstation was running Windows 7. Everything ran as well on Node.js on Windows as it did on my Linux server. It was a nice and simple setup; develop locally, test locally, deploy on server. ## Enter CouchDB Then I added a database. Specifically CouchDB that only worked on Linux. This meant a new, more complex development routine; develop locally, deploy on server, test on server, rince and repeat in case of error. This worked for a while but lately as the code has gotten more complex and it does a lot of pre-caching on startup, I've been longing for a locally deployed test version again. ## The

Cleaning up | November 26, 2011 at 17:22

I'm starting to have quite a few views in CouchDB and I've done my best to name them in a logical way so that I can easily see what they do by reading their names. Today I created a couple of new views and I decided that I needed to rename some old ones for clarity. Just when I was about to hit 'Save' on one of my design documents I felt a cold shiver going down my spine. I stopped and thought about it for a second and I realized that I don't have a separate database for my development environment, nor do I want to have one. This made me take a different strategy. At the moment I have a lot of views that does the same thing but are named differently. That's because I created new views, with better names, instead of removing the old ones. I will remove the old ones after I'm done making su

Double linked paging in CouchDB | November 14, 2011 at 23:56

Yesterday I said that I would look into paging, as my post count had reached 10+, so that's what I did today. Paging in CouchDB isn't all that straight forward for a bunch of reasons that I'll try to explain. Firstly, to be able to query anything in Couch you need a View. A Couch View is basically a really fast hash of your documents that is constructed with a little piece of javascript (like everything in Couch). In my case it looks like this: ````js function(doc) { if(doc.type === "blogpost" && doc.published) { emit(doc.dateTime, doc); } } ```` The execution of this code is what makes Couch so fast for reads. The magic can be read about [here](http://couchdb.apache.org/docs/overview.html) and if you're interested in how Couch maintains its indexes, then it's a good read. It

Running on Couch | November 12, 2011 at 14:21

I'm home from Øredev and I just couldn't resist using some of my new found inspiration to get some work done on the blog. Apache is no more! The blog now runs fully on node.js and I even got around to putting all my static blog posts into CouchDB and it is now read from disk (or cache most likely) and then templated with Mustache to form my blog. This means that I can finally have unique links for each blog post which should make it a bit easier for me to promote my updates. As I currently don't have any way of writing posts on the site, I use the CouchDB admin interface. This I feel will probably change some time in the future, but for now it works for me.

Sorry, sharing is not available as a feature in your browser.

You can share the link to the page if you want!