Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Versioning couchdb map-reduce functions

How do I version control my map/reduce functions for CouchDB? I'd like to be able to check them into git/github so that my teammates can easily apply them to their local test environments. I know there the replicate features in CouchDB, but I'd like to keep the db views with the source for the project.

like image 751
Travis Nelson Avatar asked Jun 29 '12 16:06

Travis Nelson


2 Answers

What you need is one of the (many) couchapp tools. Basically they all map a bunch of js files in various structures to the design doc layout used by CouchDB, and usually provide some simple push/pull mechanisms to get these in and out.

You can then git init in the main folder & be sure you are versioning your uploaded design docs.

There's a pretty good explanation http://mindeavor.com/blog/the-anatomy-of-a-couchapp just ignore the vendor/ discussion for the moment, its not required.

If you're more of a JS/node guy try https://github.com/mikeal/node.couchapp.js/ or kanso http://kan.so/ is awesome but it does a lot more; you may find you need more Couch-fu before getting into it. It's excellent however, you can get by just using kanso push to start with.

If you just want to get started, use couchapp http://github.com/couchapp/couchapp which is a python tool, probably the original one.

like image 162
dch Avatar answered Oct 05 '22 06:10

dch


We (and I'm sure most teams) do precisely as you've said. We keep our views, etc., in our source tree and commit to git. Our app is a node app, so it's particularly simple for us to slurp in the source, and save them to the DB, but this is fairly simple in any language - just come up with a naming scheme, store the JS files in a particular place, and read the files and store the data in the appropriate key structure in the appropriate _design/document in your DB.

like image 30
smathy Avatar answered Oct 05 '22 08:10

smathy