Adventures into CouchDB and Rails

May 4, 2009

Quick Tip: CouchDB with Lucene Search

Filed under: CouchDB — Tags: , , , — zdzolton @ 4:13 pm

So, I’m still loving Bob Newson’s CouchDB-Lucene external integration.

Here’s a quick way to monkey-patch on a search method:

CouchRest::Database.class_eval do 
  def search query, options={} 
    CouchRest.get "#{@uri}/_fti?#{options.merge(:q => query).to_query}" 

When Upgrading CouchDB at Some Point…

Filed under: CouchDB — Tags: , , — zdzolton @ 3:15 pm

Versioning with Mac Ports can kinda suck, and new CouchDB versions are often incompatible with the old version’s data files.

Idea: Use CouchDBX, during incompatible upgrades, as a holding pen for your local data!

  1. Download CouchDBX
  2. Replicate from your Mac Ports-installed databases to
  3. Delete “old” databases from your Mac Ports-installed CouchDB
  4. Upgrade your Mac Ports-installed CouchDB to some new, binary-incompatible version
  5. Re-create the databases in the newly-upgraded CouchDB installation
  6. Replicate from your CouchDBX databases to the Mac Ports-installed CouchDB
  7. Enjoy! Or, Profit! (You choose…)

See?! That was so bad, was it?

March 13, 2009

Behavioral Patterns

Filed under: CouchDB — Tags: , , — zdzolton @ 12:11 am

I’ve just read Sebastian Bergmann’s explanation of Objection-Relational Behavioral patterns, where he questions whether they are still useful for CouchDB. Hmm… Maybe I’m not getting something, but I feel these Object-Relational patterns are still a good match for CouchDB.

In particular, Unit of Work would be a great candidate, since the CouchDB doesn’t provide any transactional guarantees, not to mention that a CouchDB application is responsible for dealing with conflicts using domain-specific logic.

Lazy-loading “has_many” child objects seems to me necessary for performance, given that retrieving an entire object graph often takes more than one query for CouchDB anyways. I’d like to see CouchSurfer take it’s cue from how DataMapper does it.

Finally, implementing an Identity Map should be dead-simple given CouchDB’s flat ID space, with minor complexity of keeping the document GETs, by ID or from a view query, in sync. Moreover, I think it could probably be done at the level of CouchRest, so that all persistence libraries built atop it (and yes, there are already many) can reap the benefits.

I think the real problem will be getting people to stop using the word “Relational” —since we’re not talking about RDBMS’s here!

January 31, 2009

The Couch Underground, Part I

Filed under: Uncategorized — Tags: , , , — zdzolton @ 6:02 am

I aim to use CouchDB, compatibly with Rails; I’ll take any suggestion…

Should you have any, just tweet me.

Blog at