Add .count to extended documents to return how many there are.
Adds a reduce function to the default view so that an extra view doesn't have to be maintained just for the counting.
This commit is contained in:
parent
e538a3881d
commit
eb160e3141
3 changed files with 34 additions and 4 deletions
|
@ -35,8 +35,11 @@ module CouchRest
|
|||
'all' => {
|
||||
'map' => "function(doc) {
|
||||
if (doc['couchrest-type'] == '#{self.to_s}') {
|
||||
emit(null,null);
|
||||
emit(null,1);
|
||||
}
|
||||
}",
|
||||
'reduce' => "function(keys, values) {
|
||||
return sum(values);
|
||||
}"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue