Hacker News new | ask | show | jobs
by rakoo 3619 days ago
Thanks for this list. One of the pain points of CouchDB was management of users: there is only database-level granularity, which is not enough for many applications (and one-database-per-user may not be practical). I know that Couchbase Sync Gateway uses channels (http://developer.couchbase.com/documentation/mobile/current/...) that look interesting.

Do you know if there has been changes on this side for CouchDB 2.0 ?

1 comments

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?
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.