Skip to content

Commit 402ace4

Browse files
committed
Change the "finished" test to take into account the find mock of the tests
1 parent 263aed2 commit 402ace4

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/ParseQuery.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -926,18 +926,20 @@ class ParseQuery {
926926
let previousResults = [];
927927
return continueWhile(() => {
928928
return !finished;
929-
}, () => {
930-
return Promise.all([
929+
}, async () => {
930+
const [results] = await Promise.all([
931931
query.find(findOptions),
932-
Promise.resolve(callback(previousResults))])
933-
.then(([results]) => {
934-
if (results.length == 0) {
935-
finished = true;
936-
} else {
937-
query.greaterThan('objectId', results[results.length - 1].id);
938-
previousResults = results;
939-
}
940-
});
932+
Promise.resolve(callback(previousResults))
933+
]);
934+
if (results.length >= query._limit) {
935+
query.greaterThan('objectId', results[results.length - 1].id);
936+
previousResults = results;
937+
} else if (results.length > 0) {
938+
await Promise.resolve(callback(results));
939+
finished = true;
940+
} else {
941+
finished = true;
942+
}
941943
});
942944
}
943945

0 commit comments

Comments
 (0)