What backend i should use

Hi I am new to ionic and learning it for past 3-4 weeks. I am working on a news discussion app and looking for a solution which will

  1. allow user authentication
  2. sync between offline and online data (articles, comments etc). User can read articles offline and If a user post comment when he is offline then it should get posted when he is online.

I read that PouchDB is the right choice. Is there any other services which allows for sync between offline and online data. Can Backand and Firebase manage the sync.

You can handle offline/online issue you self using your own Database mechanism too.

you can use sql light for your client side and use one of technology between 10000000 for your server side.

or use local storage of ionic too for your client side (I don’t suggest).

PouchDB is a really good solution for this issue because it allows you to sync information between a local storage solution and a remote storage solution. Firebase and Backand are also good choices but they do not manage offline mode well/at all.

Couchbase or Hoodie are other good solutions built ontop of the PouchDB/CouchDB mix. Hoodie and Couchbase also seek to further abstract away from implementing the PouchDB & CouchDB yourself if that is something you would like.

1 Like

Thanks for the information James. I will be going with PouchDB/CouchDB mix.

Have you used Couchbase or Hoodie . If yes how was your experience.

I haven’t used them personally as I’m currently working with pouchdb/couchdb in one of my apps but I have heard good things. If your not in a major hurry perhaps build two small test apps such as a todo app using hoodie and couchbase and see how they compare to pure PouchDB/CouchDB.

That is a good idea. thanks.

1 Like

The choice of a backend depends on (too) many things, but here are some key factors you might consider before investing time to learn a backend:

  1. Run the backend yourself, or prefer MBaaS?
  2. Usage profile of the app - amount of users and typical patterns of requests per user over time?
  3. Budget? Also, do you wish to have a free tier for development - typically for an app in production one could have something like 10 versions in testing / development running parallel. It is nice to have the 10 ones free…
  4. Do you have a preference about SQL / NoSQL?
  5. Do you wish to have social identities (FB, Twitter, Google etc.) for user authentication?
  6. Offline / caching - do you wish it to be provided by the backend client libraries, or do you wish to implement it yourself?
  7. Do you wish to use a javascript client library or a REST API? For JS, is integration with Angular or even Ionic important?
  8. Search - how important is search for you (full text search especially)?
  9. Backend code - do you wish to run some of the code in the backend?

MBaaS will be easiest, handling most of the heavy lifting for you.

PouchDB is great and works seamlessly with CouchDB, especially when using replication to sync offline usage. CouchDB is great, my favorite NoSQL DB – I really prefer it over Mongo myself, but it seems Mongo is winning in popularity.

For #1 you have options for CouchDB;
run CouchDB in cloud, in a Docker container it is extremely easy. A $10 / month server will get you far already… But you have to manage it yourself / backups, availability, updates, scaling etc. You have to invest a lot of time to set it up securely and properly configured. Then, later some time every week to keep things running smoothly.
Since Couch has built-in users / authentication and authorization, replication and such, it is almost a full MBaaS in itself. Not so many providers for CouchDB, though. You can have Couch from Cloudant.
But the bad news with Cloudant: if you have many users, you’d better not use replication with the app, the pricing is per request, and continuous replication will be making a lot of requests.
For #5, CouchDB has excellent user management in itself, but no integration with social identities. You have to implement an FB login yourself over it.
Search is tricky… Couch has its own style. Do not expect anything to be easy like in SQL – SELECT * FROM ARTICLES WHERE OWNER LIKE 'John%' won’t work… You have to build views and use map/reduce. Couch 2.0 will add queries like Mongo, and Cloudant already has them, I think.

So, it will be easier but it’s never full text search - not with any of these MBaaS options. For that, you need Elastic, Algolia or something else to complement your DB. In any case, more costs and headaches, so full text or fuzzy search should not be the 1st priority without a real reason…

Firebase
Optimized for real-time usage. Data is a single tree and modeling your data + queries (for me at least) need a little extra thinking to get them right. Their offline support is not meant for what you describe (so, implement offline support yourself). Pricewise, actually very cheap nowadays. Basic search / queries are possible, and seem to be performing OK. No full text search here either.

Mongo alternatives…
You can run Mongo yourself, or have it hosted, or as a part of MBaaS: Many - seems most MBaaS companies use Mongo as their DB. So did Parse – a very nice MBaaS with push messaging, analytics and all. But when FB decided to kill Parse, it scared a lot of MBaaS users; what would they do if their MBaaS was killed as well - having to rewrite the apps and transfer all the data and what not…

Something I’ve been studying myself: Kinvey - one of the promising (Mongo) MBaaS companies. They even have an Ionic starter: https://market.ionic.io/starters/kinvey-starter
Authentication, social identities, push messaging, Ionic/Angular client libraries (with offline support) etc.
Their pricing is per monthly active user, so you can use sync. If you have less than 1000 users it’s free. If you have less than 100 000 users and 30 GB of data, you pay $200 monthly. Sadly at 100 001 users or 31 GB you end up paying $2000 a month - quite a step…
Offline support seems to be getting better in their next client library but that is currently in beta. The current version has offline support, but is not that comprehensive yet.
Text searches are limited to “starts with” kind of queries, but seem to be performing OK.

With all the NoSQL databases, you have to think how to organize and save your data / denormalizing and keeping the hierarchy optimized for you usage. Still, it is easier and more flexible than SQL indexing, tables and joins… :slightly_smiling:

MORE OPTIONS
If you are interested in MBaaS - there’s a collaborative list of many alternatives on Git: https://github.com/relatedcode/ParseAlternatives

OFFLINE
For #6: You might consider implementing the offline capabilities yourself in code, not syncing or using the client libraries of the backend… Avoid local storage, and be aware of the (size and stability) limitations of IndexedDB and WebSQL. IMHO, for an Ionic app, use SQLite - either directly, or via PouchDB.
Cordova/PhoneGap + SQLite Plugin: if you include this plugin in your project, then even PouchDB will automatically use that instead.

SERVER CODE
Tough one - makes a lot of sense to run some code in the cloud. Makes it easier to update functionality for existing apps, or to make them more secure as the clients do not get to write to DB directly.
Many MBaaS platforms enable you to run NodeJS code before or after DB calls, or on their own to respond to a call from the app. Parse had this, Kinvey has it. Firebase sadly does not.

HOSTING
If you have a web app, or need to serve some content for the app outside of the DB, you need hosting as well. Firebase has it, Parse had it, Kinvey sadly not.

5 Likes

Thanks a lot for explaining things to a beginner like me. I made the choice of the following:

  1. offline support
  2. SQL preference. I do not have experience working with NoSQL.
  3. MBaaS
  4. Angular/Ionic integration peferred.

What option will suit me? Please advise.

I have not found an option which offers offline/online sync with MySQL. Thanks.

NoSQL is surprisingly easy. It’s all JSON (or documents, instead of linked tables), so it’s easy in javascript.

For 1 + 3 + 4 Kinvey is a good option. Take a look at their docs at dev center. Client libraries next gen / Beta documentation is not up to date, so look for the current production version. They have Angular support and an Ionic starter.

But for 2 + 3 + 4 … I think Backand is one good option.
I checked, and you can link an external DB (SQL ones supported), or their own - which seems to be MySQL. You can create tables with links, and make queries using SQL. They too have Angular support and an Ionic starter.
Offline support I could not find out of the box, but you can code it yourself - externalize all DB calls to a service, which keeps track of online/offline status and makes CRUD operations accordingly. Offline create; save locally, mark as not saved remotely, check for online status and post those remotely once connected. A bit tricky to get it just right, though…
Quality, support, docs, community etc: I have no real experience on Backand, so maybe someone else using it might comment on them.

Maybe take a look at the two Ionic starters at the marketplace (free both) and test with a simple example?

( As said, PouchDB + Cloudant (=CouchDB) is still great for wonderful offline sync, but might get expensive to use. )

I’m currently using PouchDB and Cloudant. I’ve used Couchbase and I’m starting with Hoodie just now.

With PouchDB + CouchDB (or Cloudant), I solve the whole authentication problem with SuperLogin. It does everything you may need, from creating a user and confirming the email to linking social providers like Facebook.

Couchbase needs work to be done on the server to be like SuperLogin. Their docs could get an upgrade.

Hoodie is very good, and it aims to be more than authentication, with things like purchases and sending emails. The Hoodie team and community are awesome, very welcoming :slight_smile:

Hi @EuAndreh, did you end up using Hoodie and what is your impression of it?

Hi @ashteya

I didn’t end up actually using Hoodie, I’ve just been following them. I’ve
used SuperLogin, and it’s very versatile and progressing quickly. I advise
looking it up :slight_smile:

2016-08-15 5:01 GMT-03:00 Ashteya Biharisingh <
ionicframework@discoursemail.com>:

2 Likes