Closed sheluchin closed 7 months ago
I'm thinking of adding :schema-opts
as a hash map option to specify the FK suffix and the PK column, but perhaps also a :pk-fn
that can be used instead of :pk
(column name) to turn <table>
into <table>id
or whatever since I know some folks use weird naming like that.
There's a snapshot on Clojars with :schema-opts
as well as the latest develop branch.
:schema-opts {:fk-suffix "did" :pk "did"}
would address your needs.
Is your feature request related to a problem? Please describe.
The
id
/_id
suffix is hardcoded and cannot be changed. My schema usesdid
instead ofid
. I could set each relationship up in the:schema
key, but being able to globally set a different suffix would be more convenient.Describe the solution you'd like Allow users to set a different suffix to use for datafying results in order to get lazy navigation support.
In my case, the foreign key
foo_did
does point to afoo.did
column in the referenced table, but it's conceivable that users may have schemas where the mapping is not as predictable, likefoo_fk
might point tofoo.id
. Being able to define suffix relationships that support this kind of thing would be helpful.Describe alternatives you've considered Using
:schema
to define each relationship works, but it's less convenient.Additional context Discussed in https://clojurians.slack.com/archives/C1Q164V29/p1701705842770289.