Hi again!
Thanks for taking the time to help me out!
In addition to Chris' answer: the CouchDB object is just a wrapper
object that uses AJAX to talk to CouchDB over HTTP. Again, this is
not available from within views. And while this could be added, it
sounds more like a hassle than something we'd actually want to
support.
Yes, you are right... I didn't think of the CouchDB object as a ajax
call, but more as of an direct internal call to the database, but
well, that doesn't make much sense anyway, since all database
interaction goes through the RESTful interface... Now I am
understanding a bit more. I guess I am still quite a bit stuck in my
relational database world :)
What exactly are you trying to do here? Maybe you are still trapped
(I know I often am) in the relational world and things could be
solved in a 'CouchDB way' for you.
What I am trying to do is the following:
I am having entries of different kinds in my database. Each entry has
a automatically calculated rating for each user that differs from user
to user. Based on if that rating is over a certain threshold that also
differs from user to user, and also from entry type to entry type for
each user, the entry gets displayed for the user. Additionally I want
to store a flag for each user that specifies if the user has read the
entry or not.
My first attempt was to store the user ratings in the entry itself,
and then use a for loop in the view to map the entry to each user ID,
but to store if the user has read the entry or not I would then have
to load the whole entry with all its ratings change the value of one
flag, and then save it all back. Seems like I would be loading an
awful lot of information and wasting a lot of resources(?). Maybe I am
trying to save computer cycles at the wrong place. What I ended up
doing instead is more a relational database approach:
Now I have my entry document which only is the entry itself, and then
user_entry documents that have references to the entry, stores the
users rating and a flag wether or not it has been read and if the
rating passed the users threshold or not. It works perfectly until I
want to go from a list of user_entries to a list of entries. If I load
a list of user_entries that have a certain rating I have to make a
seperate call to the database to load each entry! That is why I tried
creating a view that would check the user_entry and the return the
qualified entries directly...
Best regards
Sebastian