Ashwaq
Ashwaq

Reputation: 11

CouchDB and validate_doc_read function

The problem:

CouchDB has not be designed to support per-document read-control.

As a proposed solution:

Create Validate_doc_read function (javascript function be called on every read, in the same manner as the validate_doc_update system is applied).

In _users database I defined function inside the document like this:

"validate_doc_read": "function(doc, userCtx) {
    if ((typeof doc.name !== 'undefined') && (doc.name != userCtx.name)) {
        throw({unauthorized: userCtx.name + ' cannnot read ' + doc._id});
    }"
}

But the function does not work Why?

Upvotes: 1

Views: 195

Answers (1)

Juanjo Rodriguez
Juanjo Rodriguez

Reputation: 2131

validate_doc_read is not supported by CouchDB. Only validate_doc_update function is supported.

Per-document read permission is not supported in CouchDB

Upvotes: 1

Related Questions