I have a small project which stores data in IndexedDB in browser. I would like to add sync functionality so users can access the data everywhere.
How can I sync local IndexedDB data in a remote server or server database so I can access it everywhere? In other words, I would like to make this demo available in all of my browsers. (Security is not a problem in this phase)
In fact, there is not much on IndexedDB for synchronising database. You only need RESTful service for replicating from server to client and vice versa.
For effective synchronization, the service should support etag (HTTP spec) for each record, updated (ATOM spec) for collections. Additionally to support resumable update, totalResults, startIndex, itemsPerPage (OpenSearch spec) and ordering by updated is necessary.
When GETting a record 'If-None-Match' header of etag is specified, to get full caching benefit, When PUTting a record 'If-Match' header is specified to resolve conflict on client side. To update the collection, query is limited by updated parameter, so that only records not in the client database are returned.
That is how I attend to implement on my open source IndexedDB API wrapper. See example app https://github.com/yathit/feature-matrix in angularjs and demo.
Also look at PouchDB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With