Merge pull request #992 from TorchlightSoftware/repl-optimize

don't send queries to the DB when no changes are detected
This commit is contained in:
Ritchie Martori 2015-01-19 09:32:17 -08:00
commit 0b0927b56b
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();
});