Maybe I wasn't clear.
It is nothing ajax like.
What I am trying to accomplish is that when document X is indexed by
the view server, it maps parts of document Y in addition to itself.
I have seen the CouchDB class being used in the test suite in the
couchDB interface, so I thought that was something that also would be
available in the views?! But it is not? Is there no way for a view,
indexing the document X, to access the database and get some info?
Best regards
S
On Apr 11, 2008, at 8:11 PM, Jan Lehnardt wrote:
Views do not run in the context of a browser. So you don't have any
AJAX features there. The map function gets executed in a very
isolated environment.
You could hook up a different language interpreter for your views
that let's you access external resources, but you'd be pretty much
on your own support-wise.
Cheers
Jan
--
On 12 Apr 2008, at 00:26, Guby <[EMAIL PROTECTED]> wrote:
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