Does a design document in couchdb update view rebuilding?

Suppose I have a project document with views, update functions, etc. Now suppose I am updating a project document by adding a validation handler. This will cause the views defined in this project document to be restored even if I don’t change the view function at all.

+6
source share
2 answers

No, views are not restored until the views property is changed. CouchDB computes a hash on the views property of the design document and uses this hash as the name of the view file.

We use this function a lot: we regularly update our project documents, and until the representations themselves change, the representations are not restored.

BTW: This is also the reason you can use the CommonJS and require() modules in your views, but you are limited by the paths within the views . You can do this, for example:

 { ... "views": { "lib": { "underscore": "... (underscore.js here)" }, "my_view": { "map": "function (doc) { var _ = require('views/lib/underscore'); emit(doc._id, _.pick(doc, 'name', 'address'); }" } } } 

But you cannot use require as follows: var _ = require('underscore');

Hope this helps!

+5
source

Yes. As described in the View API (section “Modifying / Modifying Views”) in the Wiki:

To change a view or several views, just change the project document (see HttpDocumentApi), they are saved and saved in the new edition. This forces all the views in this project document to be rebuilt on next access if the view code has been changed.

Please note that the documentation refers to updating the project document, not its fields.

+3
source

All Articles