views:

181

answers:

2

I am new to CouchDB way of making things. So, I have a lot of questions about it, but let's focus in one of them.

CouchDB has this concept of javascript code (validation + map-reduce + show + ?) being written in the design documents. This is part of the database, like stored procedures or triggers are for more tradittional databases.

Is there anybody maintaining this code inside a project so that we can actually test this code like any other javascript code (through jspec for instance, mocking the dependencies), version in the same repository we version the rest of our code, probably in a separate folder.. is it possible and used? Or isn't it good for some reason I should know?

What I would like to have is some way to do a single rake task and my couchdb design documents get synced with the project, something like that might be useful.

In the case of ruby, it would be helpful also to make some dynamic magic happen (e.g. default views and validations, new views through the use of named scopes).

+4  A: 

Check out CouchApp: http://github.com/couchapp/couchapp

It's a set of python scripts that take a structured filesystem of js files (amongst others) and converts it into a well-formed Design Doc.

(Pardon me if I misunderstood your question)

Dominic Barnes
There's at least one other implementation of this concept, which I actually just finished the initial spike of -- using clojure: http://github.com/cemerick/clutch/commits/clutchapp One addition I added that couchapp doesn't currently provide is an easy way to clone all design documents found in a particular database and/or couchdb install to disk. Cheers,
Chas Emerick
A: 

Yeah, we keep our view code in files and check them in to git and then use a sync script to push them to production once we're confident they work.

mikeal