ujjwalguptaofficial / JsStore

Simplifying IndexedDB with SQL like syntax and promises
http://jsstore.net/
MIT License
858 stars 110 forks source link

need example for syncing offline data with server #13

Closed sachin0606 closed 6 years ago

sachin0606 commented 6 years ago

Please provide any example to use api sync for offline sync data.

ujjwalguptaofficial commented 6 years ago

apis are by default synchronous in JsStore.

Here is a example to test this - you call two apis - insert first and after that select. So first insert will be executed and after that select . Baiscally call to apis will be executed in the same order as they are called one after one.

sachin0606 commented 6 years ago

how to get the offline mofied data [changed data] from jsstore. and send to server to update the data.

ujjwalguptaofficial commented 6 years ago

You need to check whether user is online or offline. So if user is online then sync with server and if offline save the data in jsstore.

here is doc for checking online and offline - https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/Online_and_offline_events

ujjwalguptaofficial commented 6 years ago

I will create a demo for this.

sachin0606 commented 6 years ago

My Scenario is to get the changed data while offline and send it to server and get the data from server which is updated while the device is offline.

indirect offline sync.

mjgr0013 commented 6 years ago

This requirement is for something like a chat or live application?

ujjwalguptaofficial commented 6 years ago

User logged in, some data is downloaded and saved into indexeddb. The process continues and when the user goes offline , the data is saved or updated into indexeddb. Now this data needs to be sent to server or sync data with server when user comes online.

This will be a use case of above scenario.

sachin0606 commented 6 years ago

yes. exactly.

udaychy commented 6 years ago

Hi @sachin0606, Here is a Chat room demo made using Jsstore. Have a look and i guess you will get the idea for your query and the code as well.

ujjwalguptaofficial commented 6 years ago

@sachin0606 - Are we good here. Please let me know.

Thanks

ujjwalguptaofficial commented 6 years ago

Hope above solutions is working for you , if not let me know. Closing the issue for now, feel free to reopen.

Thanks