Skip to content

Instantly share code, notes, and snippets.

@pmanijak
Last active August 29, 2015 14:04
Show Gist options
  • Save pmanijak/d1d261ba5704706703ef to your computer and use it in GitHub Desktop.
Save pmanijak/d1d261ba5704706703ef to your computer and use it in GitHub Desktop.
Example CouchDB design document with map-reduce
// Most of the times an aggregation function is needed,
// it is a simple count or sum, which are supported by
// built-in functions of both CouchDB and MongoDB.
//
// This is a CouchDB design document:
var circlesDesignDoc = {
url: '_design/circles',
body: {
version: "1.0.1",
language: "javascript",
views: {
count: {
map: function (doc) {
if (doc.type === "circle") {
emit(null, doc._id);
}
},
reduce: "_count"
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment