Commit Graph

9 Commits

Author SHA1 Message Date
Miroslav Bajtoš 628e3a30ca Return new checkpoints in callback of replicate()
Extend `PersistedModel.replicate` to pass the newly created checkpoints
as the third callback argument.

The typical usage of these values is to pass them as the `since`
argument of the next `replicate()` call.

    global.since = -1;

    function sync(cb) {
      LocalModel.replicate(
        since,
        RemoteModel,
        function(err, conflicts, cps)
          if (err) return cb(err);
          if (!conflicts.length) {
            since = cps;
            return cb();
          }
          // resolve conflicts and try again
        });
    }
2015-03-03 19:37:11 +01:00
Miroslav Bajtoš 2dc230b7cf Replication: fix checkpoint-related race condition
Rework the "replicate()" to create a new source checkpoint as the first
step, so that any changes made in parallel will be associated with
the next checkpoint.

Before this commit, there was a race condition where a change might
end up being associated with the already-replicated checkpoint and thus
not picked up by the next replication run.
2015-03-03 19:37:11 +01:00
Miroslav Bajtoš 2f9cf115c3 Support different "since" for source and target
Modify `PersistedModel.replicate` to allow consumers to provide
different "since" values to be used for the local and remote changes.

Make the "since" filters consistent and include the "since" value
in the range via `gte`. Before this commit, the local query used
`gt` and the remote query used `gte`.
2015-03-03 14:40:59 +01:00
Miroslav Bajtoš f21b29e34a test: setup GUID for all models tracking changes
Fix all test models that are tracking changes so that they have
a generated unique string id.

Make model names unique where possible to prevent tests reusing
the same model which causes unintented side effects.
2015-03-02 18:16:18 +01:00
Miroslav Bajtoš 702ecc6f72 Fix change detection & tracking
Add unit-tests to verify that all DAO methods correctly create change
records.

Rework the change detection to use the new operation hooks, this fixes
the bugs where operations like "updateOrCreate" did not update change
records.
2015-02-20 19:28:33 +01:00
Rob Halff 36e1f6840c fix jscs errors 2014-11-21 03:35:36 +01:00
Miroslav Bajtoš ea5b9d16fc Rename DataModel to PersistedModel 2014-06-05 09:56:00 +02:00
Ritchie Martori eec7bdd5f4 - Use the RemoteObjects class to find remote objects instead of
creating a cache
 - Use the SharedClass class to build the remote connector
 - Change default base model from Model to DataModel
 - Fix DataModel errors not logging correct method names
 - Use the strong-remoting 1.4 resolver API to resolve dynamic remote
methods (relation api)
 - Remove use of fn object for storing remoting meta data
2014-05-19 15:56:26 -07:00
Ritchie Martori 2f21f4ec1e Rework replication test 2014-05-15 17:30:58 -07:00