Reputation: 15152
When creating views in CouchDB, how do you guys determine which design document to use for newly created views? That is, by what principles to determine if 2 or more views are put into the same design document?
Upvotes: 2
Views: 487
Reputation: 73752
Internally, the following things happen.
When CouchDB needs to update a view with new data, it will update all views in a design document at the same time, as an optimization.
If you change anything inside the design document views
space (even changing whitespace or comments in your Javascript), CouchDB will discard the old index and rebuild the view from scratch.
Every update in a database must pass all validate_doc_update()
functions from all design documents in the database.
For these reasons, it's best to consider one design document as one application.
One exception I personally use is a _design/couchdb
document which has common views such as showing me all document conflicts.
Upvotes: 5
Reputation: 72825
I don't have much experience with couch but in general, it's a good idea to map an application to a design document. So, if you have a database foo
accessed by an application bar
, you'd have a bar
design document inside foo
which will contain all the views with that bar
will need each named according to what they serve.
The guide contains some information how to put design documents in the right places.
Upvotes: 2