couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <>
Subject Re: How to implement system hooks
Date Tue, 24 Sep 2013 08:28:50 GMT
On 09/23/2013 06:50 PM, Mike Marino wrote:
> Hi Thorsten,
> I believe you're asking how to implement read/write permissions on a
> database, but I'm a little bit confused by your subject.  If this is so,
> the normal way is to use validate_doc_update functions in a design
> document, e.g.:
> You will see the first link describes the code you linked to.

Thank you Mike, but the above is only for UPDATE meaning write validation.

However in
we are doing READ checks (if I understand the following code correctly)

after_doc_read(Doc, #db{user_ctx = UserCtx} = Db) ->
    #user_ctx{name=Name} = UserCtx,
    DocName = get_doc_name(Doc),
    case (catch couch_db:check_is_admin(Db)) of
    ok ->
    _ when Name =:= DocName ->
    _ ->
        Doc1 = strip_non_public_fields(Doc),
        case Doc1 of
          #doc{body={[]}} ->
          _ ->

My understanding is when we are the owner or admin of the doc we will
get the doc. In case we have public fields we return only those
otherwise we throw a 404.

I would like to implement the exact same behaviour for a database I am

Regarding the subject my question is how can I implement above code
either in a design document (my guess is that is not possible) or in a
custom db?

If the later then the question is how do I create my own
couch_myOwn_db.erl and let couchdb know about the existence?



Thorsten Scherler <>
codeBusters S.L. - web based systems
<consulting, training and solutions>

View raw message