lib/mongoid/contextual/mongo.rb in mongoid-5.0.1 vs lib/mongoid/contextual/mongo.rb in mongoid-5.0.2
- old
+ new
@@ -235,11 +235,11 @@
#
# @since 3.0.0
def first
return documents.first if cached? && cache_loaded?
try_cache(:first) do
- with_eager_loading(view.first)
+ with_eager_loading(view.limit(-1).first)
end
end
alias :one :first
# Return the first result without applying sort
@@ -333,10 +333,10 @@
#
# @since 3.0.0
def last
try_cache(:last) do
with_inverse_sorting do
- with_eager_loading(view.first)
+ with_eager_loading(view.limit(-1).first)
end
end
end
# Get's the number of documents matching the query selector.