Skip to content

What will be the best way to filter on a "preloaded table"? #29

Closed Answered by stephenafamo
isgj asked this question in Q&A
Discussion options

You must be logged in to vote

The reason for adding the random number is to prevent accidentally messing around with the actual query the user wants to run.

And when we consider nested preloading, (i.e. post -> preload author {users table} -> preload organization -> preload owner {users table}), the random numbers help prevent collisions.

Furthermore, if we look at it critically, the only things that can affect the preload only without affecting the rest of the query is the columns preloaded, and any nested loader. This is why these are the only things the options can modify.

To filter by the related table, we can do a regular join to the new table and filter appropriately

models.Posts(
  models.PreloadPostAuthor(),

  

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@stephenafamo
Comment options

@stephenafamo
Comment options

@hiendaovinh
Comment options

@stephenafamo
Comment options

@stephenafamo
Comment options

Answer selected by stephenafamo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants