simonedelmann / crud-kit

CRUD for Vapor 4. We all write CRUD (Create-Read-Update-Delete) routes all the time. The intention of this package is to reduce repeating code and to provide a fast start for an API.
MIT License
56 stars 8 forks source link

Using eager load on crud-kit #7

Closed alazirakaclan closed 3 years ago

alazirakaclan commented 3 years ago

First of all, thank you for a fast answer on previous issue. It was really great as great this project is. This time, I'll try to be a bit more gentle ;)

As far as I understood the documentation, there is no way to use eager load of parents, children and siblings (aka use with() on query builder) on crud-kit. Seems, I should implement it in custom public instance, but self.$tags.load(on:) requires database connection, which does not seem to be reachable from func public() -> Public

Or there is one? If so, it is a good idea to mention it in your documentation, if not - it is a good issue.

Thank you!

simonedelmann commented 3 years ago

Hey! You're welcome! I will look into this.

Without looking at the code, I am not sure if this can be solved by passing db to public(). I wonder if asynchronous code can be run there.

When I wrote this library, I didn't needed proper relationship support at that time. Maybe it is necessary to add proper support to solve this. I will have a look...

simonedelmann commented 3 years ago

I just published a new release, 1.1.0. This should allow you to load relationships for your public instance. See the updated documentation and the tests for an example.

alazirakaclan commented 3 years ago

Sounds great! I will try it!