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); }"
}
}
}

Popular posts from this blog

Lists and arrays in Dart

Converting Array to List in Scala

Null-aware operators in Dart