CouchDB: How to change the view function via javascript?
I am playing with CouchDB to see if it is possible [1] to store scientific data (simulated and experimental raw data + metadata). The big pro is a schema-less approach without using CouchDB: we have to be very flexible with metadata, since the set of parameters changes very often.
So far, I have some code to feed raw data, plots (as attachments) and hierarchical metadata (as JSON) to CouchDB documents, and wrote some Javascript prototypes for filtering and displaying. But the filtering is done on the client side (browser aka): the map function just returns everything.
How can I change (or push the second) map function of a specific _design document using simple browser-JS?
I don't think a temporary view will give a performance boost ...
Thanks for your time and answers.
[1]: Of course it is possible, but is it useful? possibly? reasonable?
[added]
Ah, jquery.couch.js (version 0.9.0) provides a saveDoc () function that can update the _design document with the new map function.
But I also tried out a query function that uses a temporary representation. Okay, "don't use it in a real product, only during development" ... But research and development is sustainable development, right?
Temporary views are cached as I noticed and it works well for ~ 1000 documents per DB. Second plus: all users (I think from 1 to 3, so a lot of user management is overkill) can work with their temporary view.
a source to share
Never use temporary views. They really only exist for developers and debugging. For more information see http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views (in particular the bold "NOTE").
And yes, because project documents are just documents with special permissions, you can run GET / POST / PUT / DELETE methods on them. However, you usually need administrator privileges to do this. So, if you allow pieces of software on the client side, you make your entire database public for read / write access - this might be fine for your application, but it's important to remember.
For example, if you restrict access to your database, but add a javascript username and password on the client side, then everyone can see that username and password.
Greetings.
a source to share