Found a solution. I'm not sure if it is the best approach, but updating my code for eager_graph from:
*eager_graph(:host).rack_filter(conditions)* to: *eager_graph(:host).join(:host_types, id: Sequel[:host][:host_type_id]).rack_filter(conditions)* seems to have done what I need. HOGI... On Friday, February 21, 2020 at 2:07:27 PM UTC-5, John Hogarty - Ho Gi Hung wrote: > > Howdy all. I'm trying to figure something out and having some issues > nailing down the appropriate syntax in my model file for the > following scenario: > > HOSTS > ---------- > id (pk) > name > cpu_count > mem_count > status > > > MOUNTS > --------- > id (pk) > host_id (fk) > name > path > type > > > HOST_TYPE > --------- > id (pk) > name > description > > > class Host < Sequel::Model(:hosts) > one_to_many :mounts, class: Mount, key: :host_id > end > > > class Mount < Sequel::Model(:mounts) > many_to_one :host, key: :host_id, class: Host > end > > > class HostType < Sequel::Model(:host_types) > one_to_many :hosts, key: :host_type_id > end > > > No physical table (join table) exists for hosts and host_type. > > I'm writing an API and an enhancement request has come in where the client > wants an endpoint for mounts with the ability to search/filtering on > host_type. So far the things I've tried come close but seem to end with a > join like: ... AS host_type ON (host_type.id = mount.host_id)... > > Additional info, I am using eager_graph. I think I know what I want, just > not sure how to set things up using Sequel to do it. Basically, if the > client wants to filter on 'METAL' as a host type, I want to show all mounts > for all hosts that have a host_type of 'METAL'. > > Hopefully I'm missing something simple that I've overlooked. Going to do > some more digging but thought I'd ask here to expedite a solution. > > Thanks, > > HOGI.... > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/e594e1fe-415b-4b39-be2b-93a024027120%40googlegroups.com.
