Last active
August 29, 2015 14:04
-
-
Save pmanijak/d1d261ba5704706703ef to your computer and use it in GitHub Desktop.
Example CouchDB design document with map-reduce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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