How to manage CouchDB code out of it?

504 Views Asked by At

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).

2

There are 2 best solutions below

1
On BEST ANSWER

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)

0
On

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.