lucian1900/Backbone.dualStorage — pull request #20 by nilbus (2012-07-30 20:21:28+00:00)
Title: Fetch with add: true

This patch fixes a bug where using `fetch(add: true)` replaces the entire collection in localStorage with the models that get added, rather than adding those models to what is already in localStorage.

Passing `add: true` to fetch tells fetch to add the models in the sync response to the collection, rather than using reset.

Normally, `Collection.add` will ignore models that already exist in the collection. The second commit accounts for that.

In the next version of Backbone, you can also call `fetch(add: true, merge: true)` to update existing models rather than ignoring those adds. This patch also accounts for that. See: https://github.com/documentcloud/backbone/commit/9ee0358cd66001b7140fa89208f441635a0c19bf