It would also be really cool to be able to create alternate views of a
model, including joins to other tables, and have them be accessible
through any association into that model. For example:
class Contact < Sequel::Model
def with_phone_numbers
self.join(:phone_numbers, :contact_id => :id)
end
end
class Supplier < Sequel::Model
one_to_many :contacts
one_to_many :contacts_with_phone_numbers, :association
=> :contacts, :via => :with_phone_numbers
end
class Customer < Sequel::Model
one_to_many :contacts
one_to_many :contacts_with_phone_numbers, :association
=> :contacts, :via => :with_phone_numbers
end
my_supplier.contacts_with_phone_numbers.each {...}
my_customer.contacts_with_phone_numbers.each {...}
That syntax might not be perfect, but it explains the requested
feature, that the details of the view (and any complicated join logic)
get stored once in the target model and not repeated in the
definitions for the multiple associations into that model.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---