paultman
paultman

Reputation: 435

Request for feedback: Couchdb setup with client replication (pouchdb) for multiple users/accounts

Before jumping into development, I'd like to get feedback on a change I'm thinking of making, moving from mongo to couch.

Basically I've got a webapp which is used to help organize users activities (todolist, calendar, notes, journal). It currently uses mongodb, but i'm thinking to move it to couch, mainly due to couches replication ability, and clientdb interaction (pouchdb). I have a similar homegrown setup on the browser using localstorage, backed by mongo, but am looking for a more mature solution.

Due to how couchdb differs from mongodb, I'm thinking that each user should have their own couch db, and their documents being each of my app components. Basically I have to move everything up a level with couch due to local db replication, and due to security.

I have 3 questions.

1) I assume that couch does not have document level security/authentication, correct? (Hence me moving each user assets to their own database, good idea?)

2) My plan is have users login to the website, then my backend nodejs code authenticates them, and sends them down some auth/session token. The javascript on the client then uses its local pouchdb data to set itself up, and also sends the replication request directly to the couchdb server (using the auth token it got from my server-side process). They should only have access to their database, since I can do per database auth access (correct?) What do you think of that setup? It should work?

3) Regarding couchdb service providers, why do they vary so much on their couch version? IE, happycouch, 1.6.1, iris 1.5, cloudant, 1.0.2? And I also hear about couchdb 2.0 coming out soon... I'd like to use cloudant, but 1.0.2 is so many versions back from a 1.6 or 1.5, if I'm not doing anything exotic, does it matter?

Bonus question :p Continuing from the last question, do you know of any services that host node.js and have local instances of couchdb available? I'd like to use my backend server code as a proxy, but not at the expense of another network hop.

Thank you very much for your feedback, Paul

Upvotes: 5

Views: 829

Answers (1)

nlawson
nlawson

Reputation: 11620

Due to how couchdb differs from mongodb, I'm thinking that each user should have their own couch db

This is a CouchDB best practice. Good choice.

I assume that couch does not have document level security/authentication, correct? (Hence me moving each user assets to their own database, good idea?)

You are correct: https://github.com/nolanlawson/pouchdb-authentication

My plan is have users login to the website...

Yep. You can just pass the cookie headers straight through from Node.js to CouchDB, and it'll work fine. nano has some docs on how to do that: https://github.com/dscape/nano#using-cookie-authentication

Regarding couchdb service providers, why do they vary so much on their couch version

The Couch community is one big happy fragmented family. :)

I'd like to use cloudant, but 1.0.2 is so many versions back from a 1.6 or 1.5, if I'm not doing anything exotic, does it matter?

1.0.2 refers to when Cloudant forked CouchDB. They've added so many of their own features since then, that they're pretty much feature-equivalent by now.

The biggest difference between the various Couch implementation is in authentication. Everybody (Cloudant, CouchDB, Couchbase) does it differently.

Upvotes: 5

Related Questions