Skip to content

Commit

Permalink
pouchdb#6230 Add allDocs() update_seq option to leveldb adapter
Browse files Browse the repository at this point in the history
Also fix readstreamOpts start -> gte, end -> lte
  • Loading branch information
dharders committed Nov 21, 2017
1 parent 1c8744c commit 808567d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packages/node_modules/pouchdb-adapter-leveldb-core/src/index.js
Expand Up @@ -873,16 +873,20 @@ function LevelPouch(opts, callback) {
limit = opts.limit;
}
if (limit === 0 ||
('start' in readstreamOpts && 'end' in readstreamOpts &&
readstreamOpts.start > readstreamOpts.end)) {
('gte' in readstreamOpts && 'lte' in readstreamOpts &&
readstreamOpts.gte > readstreamOpts.lte)) {
// should return 0 results when start is greater than end.
// normally level would "fix" this for us by reversing the order,
// so short-circuit instead
return callback(null, {
var returnVal = {
total_rows: docCount,
offset: opts.skip,
rows: []
});
};
if (opts.update_seq) {
returnVal.update_seq = db._updateSeq;
}
return callback(null, returnVal);
}
var results = [];
var docstream = stores.docStore.readStream(readstreamOpts);
Expand Down Expand Up @@ -959,11 +963,16 @@ function LevelPouch(opts, callback) {
return fetchAttachments(results, stores, opts);
}
}).then(function () {
callback(null, {
var returnVal = {
total_rows: docCount,
offset: opts.skip,
rows: results
});
};

if (opts.update_seq) {
returnVal.update_seq = db._updateSeq;
}
callback(null, returnVal);
}, callback);
next();
}).on('unpipe', function () {
Expand Down

0 comments on commit 808567d

Please sign in to comment.