4

I am working on a (HTML5) web app that uses client-side persistent storage, which is periodically synced to the server. I recently came across backbone.js and am very impressed. However, I'm a little confused as to how to implement my (assumedly quite common) use case.

So there are three seperate storage areas to sync between. The Backbone.Model objects in memory, the local HTML5 SQL storage, and the server itself. My reading on backbone.js seems to always be just two-way syncing, i.e. between local/server and Model. E.g. using the backbone-websql plugin allows syncing to local storage, but then that overwrites the server syncing!? How should I approach this'three-way' case?

When syncing with persisted storage (especially server) it will be necessary to send all relevant current record IDs with their Last Modified date, so that only modified records are returned/updated. However, from my reading, whole records are sent to the server during a query, which is faar too much data in my case. Any ideas how I can go about solving this?

Dave
  • 1,304
  • 1
  • 15
  • 19

1 Answers1

1

You should read about Backbone.sync There is a convention to redefine Backbone.sync method in adapters like backbone-websql. So store original sync function for memory-to-server syncing then add plugins. "Last Modified" logic can be easily implemented in Backbone.sync too

Igor Alekseev
  • 1,208
  • 12
  • 20