5

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?

Community
  • 1
  • 1
dhndeveloper
  • 311
  • 2
  • 15
  • not sure if it's your [article](https://www.joshmorony.com/part-2-creating-a-multiple-user-app-with-ionic-2-pouchdb-couchdb/), but I'll leave this link here as it sounds like an exact detailed answer to your question – YakovL Jan 16 '23 at 08:13

1 Answers1

1

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.

  • 1
    I did checkout "pouchdb-authentication." I ended up using "superlogin" (https://github.com/colinskow/superlogin) which creates a similar _user database and creates a user database for you. It has a lot of options as well. I will try that PouchDB search plugin and it looks like there is a CouchDB version. I was just thinking, I don't know how to handle the shared part offline after reading about that plugin. That may require a note to the user to connect to search. – dhndeveloper Jul 16 '16 at 12:53
  • Cloudant is working on something they call Envoy which addresses my question about the overall structure but its early beta (https://medium.com/offline-camp/scaling-offline-first-with-envoy-ada42d130cfc#.q7t4wbcmt).I may try that in the future. A couchdb contributor advised me to create 1-db-per-user and then do a filtered replication to create a shared database. – dhndeveloper Jul 16 '16 at 12:58
  • I'm not familiar with "filtered replication" so I'll have to look into that. You can set user permissions in the Database "Security" for a database too. That's pretty easy and what I ended up doing to provide access for admin tasks. – Bill Stephenson Oct 31 '16 at 19:26