Reputation: 2620
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.
Upvotes: 8
Views: 588
Reputation: 1542
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.
Upvotes: 7
Reputation: 27961
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.
Upvotes: 1