added count to proxy

This commit is contained in:
Daniel Kirsch 2009-07-21 14:14:58 +02:00
parent 413a7602e8
commit be7cd7442b
2 changed files with 7 additions and 0 deletions

View file

@ -59,6 +59,10 @@ module CouchRest
@klass.all({:database => @database}.merge(opts), &block) @klass.all({:database => @database}.merge(opts), &block)
end end
def count(opts = {}, &block)
@klass.all({:raw => true, :limit => 0}.merge(opts), &block)['total_rows']
end
def first(opts = {}) def first(opts = {})
@klass.first({:database => @database}.merge(opts)) @klass.first({:database => @database}.merge(opts))
end end

View file

@ -212,6 +212,9 @@ describe "ExtendedDocument views" do
rs = @us.all rs = @us.all
rs.length.should == 4 rs.length.should == 4
end end
it "should count" do
@us.count.should == 4
end
it "should make the design doc upon first query" do it "should make the design doc upon first query" do
@us.by_title @us.by_title
doc = @us.design_doc doc = @us.design_doc