Questions about offline content and sync DB

Hello everyone,

I started learning ionic (2) 1 month ago and I have some questions about managing offline content.

I want to create an app to browse a catalogue. I did some try on it (like browse my catalog with call to my REST API …), and I got a result that satisfied me. I want navigation to be faster, more fluide…
So I decided to have a look how implements offline mode, with prepopulated DB which sync when app start.

I will have a prepopulated DB with > 200K products, many categories and subcategories, filters…

For this, I saw I could use SQLLite because it has unlimited size (max free user space).
I saw on this tutorials https://gonehybrid.com/how-to-use-pouchdb-sqlite-for-local-storage-in-ionic-2/ that i could use pouchdb for sync
It s now actual? or there is a better way to do it? I want to minimise the time that It will took to sync datas. Have you some tips or good advice with the experiences you acquired?

Thanks in advance

Whatever you do: Don’t write any sync logic yourself. I did this once, it was hell.

Thanks for reply. Did you ever use tools for sync ? like firebase, pouchDB …? What kinds of advice can you give me to sync huge datas? and not doing sync logic myself ^^

I only used Contentful - which is a hosted CMS (think Wordpress, but for whatever data structure you like) with an API that also includes a Sync endpoint. But that isn’t very helpful for you as it is another use case. As you already have a database with stuff you probably don’t want to use an extra CMS but just find a way to put the database on your device.

Advice: You definitely have to think about how to handle the prepopulated DB, how to update the data after the user first installs the app.

Firebase is good for real-time apps like a Chat app.
If you want to store data by your own you should use couchdb.
It is easy to setup and you have the controller over your data. The offline sync is really easy to use.

2 Likes

@Sujan12
Thanks, i will have a look to Contentfull.

You definitely have to think about how to handle the prepopulated DB, how to update the data after the user first installs the app.

Yes for sure, I have already an idea about it.

@LoLStats
I agree with you with firebase, but that I want to be sure to do (and if It possible) :

  • have a prepopulated DB with a lot of products (> 200K)
  • sync data with remote API (For example : if price change -> update price, if new product - > add new product , if stock change -> update stock…). But I think It will take time to do this sync.

If It will take a lot of time, It’s maybe better that I do something else : example :

  • For a page like CategoriesResultPages : OnViewDidLoad or OnViewWillEnter : call my RestAPI and syncData (and not sync all data when app start)
  • Use my internal DB for things like : filter search result, show a product detail, lost internet connexion …

But that I want to keep : the possibility to browse a catalog and buy items even If I start my app with no internet connexion.

Thanks anyway for your suggestions :slight_smile: