Comment 1 for bug 401786

Revision history for this message
Stuart Langridge (sil) wrote :

The CouchDB approach is to not use temp views at all, which is why they're being removed; they're very inefficient. Instead, what you need to do is:
1. create a design document with your view in it
2. call that view to get your data

(This is akin to creating a stored procedure and then calling it, rather than making ad-hoc SQL queries, in an RDBMS).

We need to change our API to include the following:

def add_view(view_name, javascript_code, design_doc_id="design")

a function to add a new view to a specific design document (or to a "design" design document if unspecified)

This is really about education: people using our API need to understand that the way to do this properly is to follow the two-step process above, rather than doing ad-hoc temporary queries. The documentation in desktopcouch/records/doc/records.txt needs to be updated to describe this more proper approach, and to show how to test if a design document exists and create it if it does not.