Fixed a bug in the pagination code that caused it to paginate over records outside of the scope of the view parameters.
This commit is contained in:
parent
2057e59777
commit
b0dca70b02
2 changed files with 20 additions and 4 deletions
|
@ -204,8 +204,9 @@ module CouchRest
|
|||
def pagination_options(page, per_page)
|
||||
view_options = @view_options.clone
|
||||
if @last_key && @last_docid && @last_page == page - 1
|
||||
view_options.delete(:key)
|
||||
options = { :startkey => @last_key, :startkey_docid => @last_docid, :limit => per_page, :skip => 1 }
|
||||
key = view_options.delete(:key)
|
||||
end_key = view_options[:endkey] || key
|
||||
options = { :startkey => @last_key, :endkey => end_key, :startkey_docid => @last_docid, :limit => per_page, :skip => 1 }
|
||||
else
|
||||
options = { :limit => per_page, :skip => per_page * (page - 1) }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue