Skip to content

Commit

Permalink
fix edge case where documents list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
caffeinated-tech committed Jul 20, 2023
1 parent cd57814 commit 1468d91
Show file tree
Hide file tree
Showing 3 changed files with 3,948 additions and 18 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -104,7 +104,7 @@ module.exports = exports = function paginationPlugin (schema, options = {}) {

// FIXME: it is possible that there is a larger overlap if there are
// multiple documents with the same value that is being sorted by
if (lastDocument && documents?.[0].id.toString() === lastDocument.id.toString()) {
if (lastDocument && documents?.[0]?.id?.toString() === lastDocument?.id?.toString()) {
documents.shift()
} else if (!!lastId && hasMore) {
// we loaded an extra item in case there was a duplicate of the lastDocument
Expand Down

0 comments on commit 1468d91

Please sign in to comment.