Hacker News new | ask | show | jobs
by y0ghur7_xxx 3617 days ago
Managing rights for users on document level granularity was pretty easy in 1.6. A simple js function (it's called a "design document") to handle the logic and you are done. Just an example:

    function(newDoc, oldDoc, userCtx) {
        if (userCtx.roles.indexOf('can-write-sessions') !== -1 || userCtx.roles.indexOf('admin') !== -1) {
            return;
        } else {
            throw ({
                forbidden: 'can-write-sessions role missing'
            });
        }
    }
Why do you think that the Couchbase Sync Gateway is better?
2 comments

Validation functions give you control on writing, but there is no control on reading: everybody can read everything. That's more or less by design, couchdb would encourage you to create another db for another set of permissions.

Couchbase's channels allow you to segregate docs with different read (or write) rights inside the same db.

It's not just rights, but the ease of doing data routing with channels. For mobile, having a full stack of an embedded mobile db, sync, and backend server solves a lot of problems.