A Count(*) View for CouchDB

I've been working with CouchDB a lot lately. The first thing I tried to do, after I loaded 1,000,000 records, is to do the equivalent of count(*). Below is the view I used to implement a "count how many records I have in this database" or "count all":


{ "_id": "_design/counts",
"language": "javascript",
"views": {
"all": {
"map": "function(doc) { emit(null, 1); }",
"reduce": "function(keys, values, combine) { return sum(values); }"
}
}
}
1 comment

Popular posts from this blog

Converting Array to List in Scala

I ported a JavaScript app to Dart. Here's what I learned.

Minification is not enough, you need tree shaking