Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I structure a multiuser pouchdb/coucdb app and authentication

I've read about 10 related stackoverflow questions on this topic that are all scattered around a similar question... I want to simplify my question around a fictional "todo" application. I'm learning to code (javascript) and I'm hitting a roadblock. My "passion" project to keep me learning is pretty complex and solves a personal travel problem. One day I hope I can give back!

Here is the fictional app:

This app will be built using Ionic 2. The offline first app will let users log in and create their own list of "to dos." These should be accessible through their mobile phone and desktop and sync. The users should also be able share their todo lists with the community who may be able to copy someone else "Todo" list. The app should also be able to query what users are doing most like "brush my teeth" or "check out my batman collection." The users should also be able to use any social network login (Facebook, twitter, google, etc).

1) How do you structure the pouchdb/couchdb database? Open to couchbase/cloudant.

Is it database per user? Is it database per role? Is it one database for everyone (I know this has security issues)?

2) Is it right to assume that you would combine each client pouchdb database in to one large database for querying?

3) Do you have to use a NodeJS backend or server?

4) Can you use Auth0 or Stormpath for authentication?

I've been researching for about 5 days and I can't figure this out. I really appreciate all the help.

EDIT: I think this explains what I need pretty well aside from Authentication which I guess could work with Bluemix?

https://cloudant.com/blog/replication-with-cloudant-pt-3/#.V38hxpMrJE6

Thoughts?

like image 703
dhndeveloper Avatar asked Nov 08 '22 12:11

dhndeveloper


1 Answers

You can manage user auth with "pouchdb-authentication" : (https://github.com/nolanlawson/pouchdb-authentication)

You can create "user" file for auth and user metadata in the CouchDB "_user" database and then create a database for each user.

You can create users and roles for each user database and "design documents" to regulate what users and roles associated with them get to do with documents (a user's "ToDo" list).

The PouchDB "search plugin" is a good way to get started on using those (https://github.com/nolanlawson/pouchdb-quick-search) and it provides an awesome way to easily find stuff.

I'm just using PouchDB/CouchDB for the app I'm building. Things I need to do on the server side I'm doing with Perl. PHP might be a better supported option but I like Perl and there are a few perl modules that interface with CouchDb, but I've done most of what I need using Curl within perl.

"Is it right to assume that you would combine each client pouchdb database in to one large database for querying?"

I don't know about that. My initial hunch is no, unless you wanted to put all your ToDo lists in one database so they can be easily shared by all. I think it might be easier to manage finer grained sharing by users if you kept user ToDos in a user database.

like image 84
Bill Stephenson Avatar answered Nov 15 '22 07:11

Bill Stephenson