Ask HN: Best way to sync data with JavaScript?
We have a mobile app written on AngularJS - Phonegap/Ionic-based, calling some REST APIs who store and process app's data.
We'd like to store data locally and synchronise it later because we are having a lot of issues with internet connection on some regions.
So basically we'd like: Data -> Local storage -> {sync mechanism} -> REST API -> Database
We implemented something but it's not working as well as we'd like.
Any ideas of architecture and/or possible frameworks to solve this on a simple way?
Thanks! The IBM bluemix mobile data service sounds like a good match:
https://www.ng.bluemix.net/docs/#services/mobiledata/index.h... "With the Mobile Cloud Services SDK, you can embed a special managed directory in your application. Any files that are stored in this managed directory can be monitored and synchronized. The application can share the contents of this managed directory by connecting to Mobile Data with the same application ID and user ID. By sharing the directory contents, different instances of an application can have synchronized copies of the files" Well this is my opinion. I always thought CouchDB offers a great RESTful interface to communicate with their database. CouchDB also offers great multi-master replication, this also includes your local data. There is a JavaScript implementation of CouchDB's data sync called PouchDB. I always thought it would be a great idea to just use CouchDB as your API layer. Anything your backend needs to do goes through Couch first and get synced to the client through Pouch. I haven't experimented on the idea yet, but maybe you can take it further. Do you know Meteor - http://www.meteor.com ?
I think your idea is a quite similar to what Meteor does with MongoDB.
This is actually our 1st choice for now, but we are not closed yet. Yes, but my problem with meteor is that it's a whole package rather than pieces that I can just take what I need. Makes sense.
Thanks for your thoughts!