Closed mario-minati closed 3 years ago
I've started adding join
support to Yancy's existing backends in v1.075. Right now, only get()
has joins, but I intend to make list()
have them soon and to add querying of joined tables (largely to support role-based access controls for content). With joins and Yancy::Model, you have some more powerful, cleaner tools to build things like this :)
We implemented dbic style joins by extending the config of a single schema:
The properties are injected into the resulting schema by fetching them from referenced schema. Only those properties which are listed are injected.
The join really happens in the DBIC backend, currently on the
list
request:The schema is prepared during post processing, which currently is called after setting up the Yancy Mojolicious plugin:
We have coded this in a custom plugin, thus you see
$self
. Our DBIC schema is available via$self->app->database
.We use this only on
x-view
schemas, so we have no problem rewriting schemas that might be injected themself.The implementation of get will follow most likely.
Currently we are not looking forward to implement setter methods as this way more complex. If someone wants to implement these setters a source of inspiration could be HTML::FormFu::Model::DBIC which implemented all this complex form handling stuff with regard to DBIC data.