Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preloading #1

Open
kwrooijen opened this issue Jul 26, 2020 · 0 comments
Open

Preloading #1

kwrooijen opened this issue Jul 26, 2020 · 0 comments
Labels
discussion enhancement New feature or request

Comments

@kwrooijen
Copy link
Owner

kwrooijen commented Jul 26, 2020

Currently in order to load a relation, you need to deref the relation atom of a record. This results in a new query being executed. It would be nice to be able to preload relations, querying them with a join instead of separate queries.

A solution could be to add a new function gungnir.query/preload, which will add a :gungnir/preload '(,,,) key to the HoneySQL map. We then need to modify the query before executing it.

(-> (q/preload :user/posts)
    (q/find-by! :user/email "[email protected]"))

Another thing we need to think about is how do we adjust the result of the relation? Normally we swap! the relation atom, but in this case we'd have to do that beforehand. Maybe a function to update preloads?

(-> (q/preload :user/posts)
    (q/preload-update :user/posts q/limit 5)
    (q/preload-update :user/posts q/sort-by :post/score :desc)
    (q/find-by! :user/email "[email protected]"))
@kwrooijen kwrooijen added enhancement New feature or request discussion labels Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant