Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View d11wtq's full-sized avatar

Chris Corbyn d11wtq

  • Melbourne, Australia
View GitHub Profile
@postmodern
postmodern / dm_eager_loader.rb
Created October 27, 2011 01:34
Fork of d11wtq's DataMapper EagerLoader plugin
module DataMapper
class Collection
#
# EagerLoader takes a QueryPath object and loads all relationships
# referenced in the path, into an existing Collection.
#
# Using eager-loading allows you to optimize out the classic "n+1"
# query problem, when you intend to iterate over several arbitrarily deeply
# nested relationships. One query per relationship is executed,
# vs one query per record.