Skip to content

Commit 2305add

Browse files
authored
adapter-idb/allDocs: simplify getMaxUpdateSeq() (#8762)
1 parent fc12d33 commit 2305add

File tree

1 file changed

+4
-18
lines changed
  • packages/node_modules/pouchdb-adapter-idb/src

1 file changed

+4
-18
lines changed

packages/node_modules/pouchdb-adapter-idb/src/allDocs.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,13 @@ function idbAllDocs(opts, idb, callback) {
114114

115115
/* istanbul ignore if */
116116
if (opts.update_seq) {
117-
getMaxUpdateSeq(seqStore, function (e) {
118-
if (e.target.result && e.target.result.length > 0) {
119-
updateSeq = e.target.result[0];
120-
}
121-
});
122-
}
123-
124-
function getMaxUpdateSeq(objectStore, onSuccess) {
125-
function onCursor(e) {
117+
// get max updateSeq
118+
seqStore.openCursor(null, 'prev').onsuccess = e => {
126119
var cursor = e.target.result;
127-
var maxKey = undefined;
128120
if (cursor && cursor.key) {
129-
maxKey = cursor.key;
121+
updateSeq = cursor.key;
130122
}
131-
return onSuccess({
132-
target: {
133-
result: [maxKey]
134-
}
135-
});
136-
}
137-
objectStore.openCursor(null, 'prev').onsuccess = onCursor;
123+
};
138124
}
139125

140126
// if the user specifies include_docs=true, then we don't

0 commit comments

Comments
 (0)