Replies: 1 comment 1 reply
-
Maybe I'm missing something, but can't you achieve the same by keeping a slice of mods and then applying it? var relationMods []bob.Mod[*dialect.SelectQuery]
if someCondition {
relationMods = append(relationMods, models.SelectWhere.Bar.Field.EQ(someVal))
}
// example without any other query mods besides the relation loader
result, _ := models.Foo.Query(ctx, db, models.ThenLoadFooBar(relationMods...)) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
A lot of times I need to conditionally add one or more query mods to
ThenLoad*
-ers - those might also be nested a few levels but that's not as relevant here.Currently the Loaders cannot be changed after creation so I did wrap them in simplistic way so I can build them up as needed which looks something like this:
Then it can be used like this:
I think this use case is not that unusual.
Would it make sense to add such a capability to the
ThenLoad
directly?Beta Was this translation helpful? Give feedback.
All reactions