Hi, how do I teach next.jdbc's nav implementation about a many-many join table? Here is a working ordinary join for the sakila example dataset. And I want to navigate through {:film_actor/_film_id :actor/actor_id} . Specific qs:
β’ what attribute am I meant to hang the navigate on?
β’ how do i express the two step join?
I did read https://github.com/seancorfield/next-jdbc/blob/develop/doc/datafy-nav-and-schema.md which says > When you indicate a *-to-many relationship, by wrapping the foreign table/key in a vector, next.jdbc's implementation of nav will fetch a multi-row result set from the target table. which led me to try the following, but clearly I am missing some key concept
:film/actors [:film_actor/_film_id]
:film/actors {:film_actor/_film_id :actor/actor_id}
:film/film_id {:film_actor/_film_id :actor/actor_id}
this mapping seems coherent but it is in the wrong direction, there is no named key for the outbound edge from the film entity
{:film/language_id :language/language_id
:actor/actor_id :film_actor/_actor_id
:film/film_id :film_actor/_film_id}If you have table1 and table2 and a m2m join table with table1_id and table2_id columns, you still have two transitions for next.jdbc schema nav: table1 to (multiple) m2m rows and then from each m2m row to table2. There's no support for making multiple "jumps" in a single nav.
That :table1/col1 {...} hash map syntax is not valid currently. Only :table1/col1 :table2/col2 or :table1/col1 [:table2/col2]
Feel free to create a GH issue outlining how you'd like to be able to specify a many-to-many double-jump.
Ok, thanks makes sense. We may think about how one might specify and implement thisβunless you already have and you decided the semantics are unsound?βbut it might be a while
I had not considered it -- the two-step nav has always seemed fine to me...
when you nav from film to film_actor, which outbound column do you put the nav on? film/film_id? i.e. {:film/film_id :film_actor/_film_id} ?
The schema should map from film/film_id to film_actor/filmid and from film_actor/actorid to actor/actor_id I assume, based on what seem to be your conventions?
what if there is a second join table also connected to film/film_id, such as film->directors "many films each have many directors"
So I guess you want {:film/film_id [:film_actor/_film_id] :film_actor/_actor_id :actor/actor_id} (since film -> film_actor is 1:n)
You can only auto nav one relationship.
Remember, this whole datafy/nav stuff is a convenience for development. It's not intended for "real code".
got it, yeah i'm with you on that -- context is we're implementing web based rebl thing as an experiment
Then you'll be in the same bucket as Morse, Reveal, and Portal in terms of using datafy/nav and having it do whatever the underlying data and tooling has made available.
we have made some interesting upgrades, but that's neither here nor there
Those viewing tools don't really have any control over how datafy/nav works for any given data, beyond perhaps extending certain (Java) types for additional datafication and navigation.