Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
it('should handle user errors in reduce functions', function () {
return new Pouch(dbName).then(function (db) {
function getKey(row) {return row.key; }
db.on('error', function () { /* noop */ });
return createView(db, {
map : function (doc) {
reduce : function (keys, values) {
return values[0];
}).then(function (queryFun) {
var docs = [
{name: 'arb', _id: '0', data: {foo: {bar: 2}}},
{name: 'bar', _id: '1', data: 'quux'},
{name: 'bar', _id: '2', data: {foo: {bar: 1}}},
{name: 'baz', _id: '3', data: 'quux'}
return db.bulkDocs({docs: docs}).then(function () {
return db.query(queryFun, {group: true});
}).then(function (res) {['arb', 'bar', 'bar', 'baz']);
return db.query(queryFun, {reduce: false});
}).then(function (res) {['arb', 'bar', 'bar', 'baz']);

This comment has been minimized.

Copy link
Owner Author

@nolanlawson nolanlawson commented Apr 10, 2014

Occasionally the keys are ['arb', 'bar', 'bar', 'baz'], occasionally they are ['arb', 'bar', 'baz'].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment