1

I have created an application using javascript library D3. Users will constantly click and drag to frequently change graphical elements and I currently save the data in 3-4 local javascript objects and arrays. I want to save the data to the server periodically rather than after each change. Also I want them to be able to work if they are not connected. From twenty years ago, I imagine doing this manually where on the client side records are flagged as “new”, “revised”, and “deleted”. Every 10 seconds client data is saved via AJAX and either an object is updated or a SQL statement is executed. An id is returned from the database and saved on the client side to track each record for future modifications.

Note the data must be organized in a database for ease of separating elements for reuse. When the user is connected, updates every 5-10 seconds are fine. Then I can use an inexpensive and slow server. Of course a tool that deals with records that might not fully update is good, perhaps some transactional functionality.

There will be no separate mobile application. I can modify my javascript objects to be json compliant if need be. I see there are “offline-first” frameworks and javascript "state containers". Redux caught my eye, especially when I saw its use climbing over the years according to Google Trends. I’ve read about so many options and am thoroughly confused by all these. Here is a mish mash of tools I looked at: Store.js, now.js, indexedDB, couchDB, pouchDB, Cloudant, localForage, WebSQL, Polymer App Toolbox, Hoodie framework, Ionic and angular, and Loopback. Not to mention XHR, web sockets.

I have used MVC like Laravel and Zend, both are with PHP and MySql. I wonder if I could integrate the suggested solution. Thanks.

Related: How do I sync data with remote database in case of offline-first applications?

1 Answer 1

0

Saving the data locally using PouchDb and then syncing it with a CouchDb database (or IBM's Cloudant service) when a network connection is available is a well-trodden path for this sort of requirement. But your question is asking for an opinion, so there will be many other perfectly valid solutions to this.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks Ian, PouchDb looks like it could be the best solution. Hoodie aims to be easier but it is an entire framework and it may be too restrictive. This sounds promising Limit records synchronized in PouchDB/CouchDB
I have used PouchDb for a couple of projects now - it is well-documented (this for example is helpful) and not too steep a learning curve for those new to it. Good luck!
So far so good. That example is great because it is complete and works. Easy to sync one way or intermittently. There are plugins for authentication and relational data. Authentication with Laravel looks promising. Now I must understand and apply the samples of code. I get the idea this is the way to go.
I use bitnami.com on AWS (Amazon Web Services) but you can use all sorts of bitnami cloud providers. You see the same Fauxton interface as when you do a local install of couchDB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.