this was pretty much copy-pasted from the way we were already doing things in `allDocs` (and elsewhere in mapreduce), but you're right, that would be more readable.