Created
January 9, 2017 20:50
-
-
Save thomsbg/3044cf8be57ad21cbf3b998a3c2335e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/shared/find_each_model.js b/shared/find_each_model.js | |
index fb575db..bb671c8 100644 | |
--- a/shared/find_each_model.js | |
+++ b/shared/find_each_model.js | |
@@ -1,10 +1,12 @@ | |
var Bluebird = require('bluebird'); | |
-module.exports = function findEach(Model, fn, since, success) { | |
- since = (since == null) ? 0 : since; | |
+module.exports = function findEach(Model, fn, lastId, success) { | |
success = (success == null) ? true : success; | |
return Model.query(function(q) { | |
- return q.where('id', '>', since).orderBy('id', 'asc').limit(100); | |
+ if (lastId) { | |
+ q.where('id', '<', lastId); | |
+ } | |
+ q.orderBy('id', 'asc').limit(100); | |
}).fetchAll().then(function(models) { | |
if (models.length > 0) { | |
return models.reduce(function(p, m) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment