Dear CouchDB developers and users.
I have another view related question.

What I am trying to do is this:
Every document of type X has stored a reference to document Y. Based on certain parameters in X i decide whether or not to load and return document Y from the DB.

The view code I am trying to use looks something like this:

function(doc){
        if (doc.class == "OfTypeX" && doc.an_attribute == true){
                var db = new CouchDB("mydb");
                var doc2 = db.open(doc.id_of_object_Y);
                map([doc.another_attribute, doc.id_of_Y], doc2);
        }
}

Whenever I include the line "var db = new CouchDB('mydb');" in my view everything stops... It works perfectly in the Javascript Shell though!
Any ideas?
Aren't you allowed to access the DB directly from a view?
Is there a way to access other documents than the one being passed in to the view, from a view? I realize though that these kinds of views might lead to stale data as the view index doesn't get updated if the document Y gets updated, but that is all right in my case.

Best regards
Sebastian

Reply via email to