Skip to content

Instantly share code, notes, and snippets.

@aviflax
Created April 6, 2011 02:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aviflax/905048 to your computer and use it in GitHub Desktop.
Save aviflax/905048 to your computer and use it in GitHub Desktop.
CouchDB map/reduce view for getting max integer ID
function(doc) {
emit(null, doc._id);
}
function(keys, values) {
var ids = []
values.forEach(function(id) {
if (!isNaN(id))
ids.push(id);
});
return Math.max.apply(Math, ids)
}
@tmpvar
Copy link

tmpvar commented Apr 6, 2011

rejuice it, with math!

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