Displaying articles with tag couchdb

Couch Trouble

Posted by code_monkey_steve, Tue May 26 11:12:00 UTC 2009

I’ve been wrangling with CouchDB for a few weeks now, and it’s starting to feel a bit like this:

(Ooh, my first embedded video. Feel the Web 2.0 Awesome-ness-age-ality).

First, let me say that I can’t really blame CouchDB for any of my troubles, which are essentially:
  • There are a excess of Ruby/Rails gems for accessing CouchDB, all of whom have different dependencies and do things in slightly different ways. I’m sure that eventually a consensus will emerge on the best Ruby/CouchDB way of doing things, but it hasn’t happened yet.
  • CouchDB is not yet 1.0, so the design can support lots of spiffy features that don’t actually exist yet. Specifically, the lack of partial replication stalled my attempts at using Couch for a distributed media server project.
  • CouchDB doesn’t work perfectly for absolutely everything (whoda thunkit?). My other big project (more on that later) isn’t really Document-Oriented, no matter how much I try to beat it flat. I’m now thinking Git is actually be best storage solution, and if you understand Gits internals well enough, you’ll see how mind-warping that concept is.

So I think I’ll put CouchDB down for a while, at least until 1.0, or until I run across a project where it’s appropriate. Of course, it’s still a gazillion times better than any RDBMS

0 comments | Filed Under: | Tags: couchdb

CouchDB Testing Tip

Posted by code_monkey_steve, Wed May 13 13:52:00 UTC 2009

Finished my first stab at converting my current toy project from AR to CouchDB, and so far so good. I ran into an issue where associations aren’t getting saved, but I’m most likely just doing something stupid.

One minor annoyance is that, unlike ActiveRecord, the test database doesn’t get purged and after a while can get cluttered with randomly-generated fixtures1. No problem, just drop in this little Rake task to recreate the DB on each run:

# lib/tasks/couchdb.rake
require File.expand_path( RAILS_ROOT + '/config/environment' )
require 'couch_potato'

task 'couchdb:test:purge'  do
  CouchPotato::Config.database_name = 
    YAML::load(File.read(Rails.root.to_s + '/config/couchdb.yml'))['test']
  CouchPotato.couchrest_database.recreate!
end
task 'db:test:purge' => 'couchdb:test:purge'

1 BTW, have I mentioned how cool factory_girl is? Another new tool for my bag of tricks.

2 comments | Filed Under: | Tags: couchdb

CouchDB: Frankie Says Relax

Posted by code_monkey_steve, Tue May 12 11:49:00 UTC 2009

I’m falling in love (or at least lust) with CouchDB, especially after seeing this presentation at AAC and this presentation for the BBC. My summary: JSON document storage, sliced-and-diced with Javascript MapReduce, all served on a RESTful platter.

As a long-time XML fanboy, the lack of schema in JSON makes me a bit twitchy, and using Javascript as a query language just looks a lttle wrong. But I see the advantages to the document-centric model (versioning, replication, access control) and MapReduce is definitely the Wave of the Future Present. It looks like you can encapsulate all of your model logic in views, so I’m not sure if an explicit schema is really even necessary. The more I learn about That Way of doing things, the more it grows on me.

So how do we make CouchDB play nicely with Rails? I first tried activecouch, but found its lack of Ruby-type casts and one-database-per-model scheme irritating. couch_potato definitely looks slicker, but there seems to be quite a few other CouchDB interfaces out there that might be just as good or better. I see this as a good sign that many others also see CouchDB’s potential, and are experimenting with ways to deal with it in a Ruby Way.

0 comments | Filed Under: | Tags: couchdb