- Defined in:
This will work for embedded relations that reference another collection via belongs_to as well.
Eager loading brings all the documents into memory, so there is a sweet spot on the performance gains. Internal benchmarks show that eager loading becomes slower around 100k documents, but this will naturally depend on the specific application.
Eager loads all the provided relations. Will load all the documents into the identity map who’s ids match based on the extra query for the ids.
218 219 220 221 222 223 224 225
# File 'lib/mongoid/criteria.rb', line 218 def includes(*relations) relations.flatten.each do |name| = klass.reflect_on_association(name) raise ::.(klass, relations) unless inclusions.push() unless inclusions.include?() end clone end