couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joscha Feth" <jos...@feth.com>
Subject Limiting views to special users
Date Mon, 28 Dec 2009 11:59:02 GMT
Hello there,

I am using couchdb to store hierarchical data - one of the documents of
this hierarchy contains some information about users being allowed to
access the data (e.g. a user name which has access).
Now the problem is: I can not just obey emitting the documents within
my view, as there is no information in the majority of documents - so
my idea was to raise an exception as soon as I see the document
containg the credentials and the user *not* having access.

You can try this behaviour with a simplified temporary view:

function(doc) {
  if(Math.random() > 0.7) {
    throw({forbidden : "Buh!"});
  }
  emit(null, doc);
}

Now it seems to work fine generally, but there are three things which
worry me:
* the map function still seems to be run on documents even after the
exception has been thrown (which is unnecessary).
* the results of the view seem to be cached, even though Math.random()
may change at each invocation - is this something specific to the
temporary views (I used this for testing) or is this the default
behaviour?
* The return code is still a 200, I would have expected an error return
code.

Anyone seeing a better alternative for completing my task? Any
hints/caveats about my current approach?

regards,
Joscha

-- 



Mime
View raw message