don't send queries to the DB when no changes are detected

This commit is contained in:
bitmage 2015-01-10 11:28:55 -07:00
parent 32ed60904c
commit c28698c1ba
2 changed files with 4 additions and 0 deletions

View File

@ -344,6 +344,9 @@ module.exports = function(Change) {
*/
Change.diff = function(modelName, since, remoteChanges, callback) {
if (!Array.isArray(remoteChanges) || remoteChanges.length === 0) {
return callback(null, {deltas: [], conflicts: []});
}
var remoteChangeIndex = {};
var modelIds = [];
remoteChanges.forEach(function(ch) {

View File

@ -728,6 +728,7 @@ PersistedModel.changes = function(since, filter, callback) {
modelName: this.modelName
}, function(err, changes) {
if (err) return callback(err);
if (!Array.isArray(changes) || changes.length === 0) return callback(null, []);
var ids = changes.map(function(change) {
return change.getModelId();
});