Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including couchdb-view-tester with all npm packages installed. Try it out:

var couchdbViewTester = require("couchdb-view-tester")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

couchdb-view-tester v3.1.2

Your friendly helper to quickly iterate on CouchDB views

couchdb-view-tester

Your friendly helper to quickly iterate on CouchDB views

CLI usage

# npm install -g couchdb-view-tester
couchdb-view-tester <db url> [--watch] --map=<path to map function> --reduce=<path to reduce function> <view options>

Example

Give your CouchDB database you want to test your map/reduce function on is accessible at http://localhost:5984/mydb, do

couchdb-view-tester http://localhost:5984/mydb --map=./path/to/map.js --reduce=./path/to/reduce.js --limit=3

Both, map.js and reduce.js must return an anonymous function, for example

// map.js
module.exports = function(doc) {
  if (doc.Type == "customer") {
    emit(doc._id, doc.LastName);
  }
}
// reduce.js
function (key, values, rereduce) {
  return sum(values);
}

View options

Options are equal to PouchDB's db.query options: http://pouchdb.com/api.html#query_database

Future plans / ideas

  • add support for built in reduce functions
  • add support for map functions only
  • add docs for usage via require('couchdb-view-tester')
  • add yours™

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free