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:
commit
0b0927b56b
|
@ -344,6 +344,9 @@ module.exports = function(Change) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Change.diff = function(modelName, since, remoteChanges, callback) {
|
Change.diff = function(modelName, since, remoteChanges, callback) {
|
||||||
|
if (!Array.isArray(remoteChanges) || remoteChanges.length === 0) {
|
||||||
|
return callback(null, {deltas: [], conflicts: []});
|
||||||
|
}
|
||||||
var remoteChangeIndex = {};
|
var remoteChangeIndex = {};
|
||||||
var modelIds = [];
|
var modelIds = [];
|
||||||
remoteChanges.forEach(function(ch) {
|
remoteChanges.forEach(function(ch) {
|
||||||
|
|
|
@ -728,6 +728,7 @@ PersistedModel.changes = function(since, filter, callback) {
|
||||||
modelName: this.modelName
|
modelName: this.modelName
|
||||||
}, function(err, changes) {
|
}, function(err, changes) {
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
if (!Array.isArray(changes) || changes.length === 0) return callback(null, []);
|
||||||
var ids = changes.map(function(change) {
|
var ids = changes.map(function(change) {
|
||||||
return change.getModelId();
|
return change.getModelId();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue