Permalink
Browse files

Merge pull request #62 from matthiasjakel/master

Massive performance improvement when fetching the first document of a view
  • Loading branch information...
langalex committed Apr 18, 2012
2 parents aa743e7 + 65086ea commit 64633b5f477448c35effcd7ae65ef4e79f7ead59
Showing with 4 additions and 2 deletions.
  1. +1 −0 lib/couch_potato/database.rb
  2. +3 −2 lib/couch_potato/view/base_view_spec.rb
@@ -64,6 +64,7 @@ def view(spec)
# returns the first result from a #view query or nil
def first(spec)
+ spec.view_parameters = spec.view_parameters.merge({:limit => 1})
view(spec).first
end
@@ -1,8 +1,9 @@
module CouchPotato
module View
class BaseViewSpec
- attr_reader :reduce_function, :list_name, :list_function, :design_document, :view_name,
- :view_parameters, :klass, :options, :language
+ attr_reader :reduce_function, :list_name, :list_function, :design_document, :view_name, :klass, :options, :language
+ attr_accessor :view_parameters
+
private :klass, :options
def initialize(klass, view_name, options, view_parameters)

0 comments on commit 64633b5

Please sign in to comment.