jgaskins / perpetuity

Persistence gem for Ruby objects using the Data Mapper pattern
http://jgaskins.org/blog/2012/04/20/data-mapper-vs-active-record/
MIT License
250 stars 14 forks source link

Load partial associations #46

Open jgaskins opened 10 years ago

jgaskins commented 10 years ago

If a user has a mailbox which has thousands of messages in it, loading all of them is a huge waste when they are likely to only view the latest 2 or 3 messages. We need some kind of syntax that limits which associated objects we want. The only idea I've got:

# Load messages 20 through 40 (exclusive)
mapper.load_association! mailbox, :messages, 20...40