Skip to content

Commit

Permalink
Merge pull request #19 from SQiShER/disable-reduce-for-view-queries
Browse files Browse the repository at this point in the history
Disable use of reduce function for view queries
  • Loading branch information
cliffano committed Mar 17, 2019
2 parents 42148a8 + ce71560 commit 134f214
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/db.js
Expand Up @@ -51,7 +51,8 @@ Db.prototype.paginate = function (interval, startKey, endKey, pageSize, numPages
startkey: key,
startkey_docid: key_docid,
limit: pageSize + 1,
include_docs: true
include_docs: true,
reduce: false
};

// unlike startkey/startkey_docid, null endkey/endkey_docid does not mean last document in the database
Expand Down
4 changes: 4 additions & 0 deletions test/db.js
Expand Up @@ -16,6 +16,7 @@ buster.testCase('db - paginate', {
assert.equals(opts.endkey, 'someendkey');
assert.equals(opts.endkey_docid, 'someendkey');
assert.isTrue(opts.include_docs);
assert.isFalse(opts.reduce);
assert.equals(opts.limit, 3);
assert.equals(opts.startkey, 'somestartkey');
assert.equals(opts.startkey_docid, 'somestartkey');
Expand All @@ -34,6 +35,7 @@ buster.testCase('db - paginate', {
assert.equals(opts.endkey, undefined);
assert.equals(opts.endkey_docid, undefined);
assert.isTrue(opts.include_docs);
assert.isFalse(opts.reduce);
assert.equals(opts.limit, 3);
assert.equals(opts.startkey, 'somestartkey');
assert.equals(opts.startkey_docid, 'somestartkey');
Expand All @@ -49,6 +51,7 @@ buster.testCase('db - paginate', {
assert.equals(opts.endkey, undefined);
assert.equals(opts.endkey_docid, undefined);
assert.isTrue(opts.include_docs);
assert.isFalse(opts.reduce);
assert.equals(opts.limit, 3);
assert.equals(opts.startkey, 'somestartkey');
assert.equals(opts.startkey_docid, 'somestartkey');
Expand All @@ -62,6 +65,7 @@ buster.testCase('db - paginate', {
var mockNano = {
list: function (opts, cb) {
assert.isTrue(opts.include_docs);
assert.isFalse(opts.reduce);
assert.equals(opts.limit, 3);
cb(null, { rows: [{ _id: 'someid1' }, { _id: 'someid2' }, { _id: 'someid3' }, { _id: 'someid4' }]});
}
Expand Down

0 comments on commit 134f214

Please sign in to comment.