1
votes

I am creating a web site to store data offline and then sync it with online database. I'm planning to implement it via indexeddb but that won't be permanent besides client want two copies of data one on client side and second on server side.

My queries are:-

  1. Is it possible to store indexeddb data in local server.
  2. Is it possible to store data in local sql server using javascript or any client side technology.

Any suggestions will be welcome.

Thank You.

1

1 Answers

0
votes

Have a look at Pouchdb.

PouchDB is an open-source JavaScript database inspired by Apache CouchDB that is designed to run well within the browser.

It enables applications to store data locally while offline, then synchronize it with CouchDB and compatible servers when the application is back online, keeping the user's data in sync no matter where they next login.

So, it will meet your requirement "to store data offline and then sync it with online database". PouchDB is build on top of IndexedDB, so you will be able to take advantages of IDB.

With PouchDB, server side database has to be CouchDB, but still you can check with other server side database sync options are available. As per my knowledge there is no framework/library available which enables to sync SQL database.

If you have to sync client database data with only SQL server then you have write your own framework to do so, which means

  • Using JS setInterval or some other mechanism to send client db data to server periodically
  • Capture the delta (db updates once client is offline) and send it to server once client is back online.