How to use pouchdb-abstract-mapreduce - 2 common examples

To help you get started, we’ve selected a few pouchdb-abstract-mapreduce examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pouchdb / pouchdb / packages / node_modules / pouchdb-find / src / adapters / local / abstract-mapper.js View on Github external
throw new Error('reduce not supported');
}

function ddocValidator(ddoc, viewName) {
  var view = ddoc.views[viewName];
  // This doesn't actually need to be here apparently, but
  // I feel safer keeping it.
  /* istanbul ignore if */
  if (!view.map || !view.map.fields) {
    throw new Error('ddoc ' + ddoc._id +' with view ' + viewName +
      ' doesn\'t have map.fields defined. ' +
      'maybe it wasn\'t created by this plugin?');
  }
}

var abstractMapper = abstractMapReduce(
  /* localDocName */ 'indexes',
  mapper,
  reducer,
  ddocValidator
);

export default function (db) {
  return db._customFindAbstractMapper || abstractMapper;
}
github pouchdb / pouchdb / packages / node_modules / pouchdb-mapreduce / src / index.js View on Github external
return builtIn;
  } else {
    return evalFunction(reduceFunString);
  }
}

function ddocValidator(ddoc, viewName) {
  var fun = ddoc.views && ddoc.views[viewName];
  if (typeof fun.map !== 'string') {
    throw new NotFoundError('ddoc ' + ddoc._id + ' has no string view named ' +
      viewName + ', instead found object of type: ' + typeof fun.map);
  }
}

var localDocName = 'mrviews';
var abstract = createAbstractMapReduce(localDocName, mapper, reducer, ddocValidator);

function query(fun, opts, callback) {
  return abstract.query.call(this, fun, opts, callback);
}

function viewCleanup(callback) {
  return abstract.viewCleanup.call(this, callback);
}

export default {
  query: query,
  viewCleanup: viewCleanup
};

pouchdb-abstract-mapreduce

PouchDB's secondary index API as an abstract module

Apache-2.0
Latest version published 1 year ago

Package Health Score

81 / 100
Full package analysis

Popular pouchdb-abstract-mapreduce functions