lib/mongoid/contextual/mongo.rb in mongoid-4.0.1 vs lib/mongoid/contextual/mongo.rb in mongoid-4.0.2
- old
+ new
@@ -200,9 +200,19 @@
end
end
end
alias :one :first
+ # Return the first result without applying sort
+ #
+ # @api private
+ #
+ # @since 4.0.2
+ def find_first
+ return documents.first if cached? && cache_loaded?
+ with_eager_loading(query.first)
+ end
+
# Execute a $geoNear command against the database.
#
# @example Find documents close to 10, 10.
# context.geo_near([ 10, 10 ])
#