How to eager load with bind #982
-
If I want to bind to a structure like: type CustomUser struct {
User models.User `boil:",bind"`
TotalPosts int `boil:"total_posts"`
} How do I user var customUsers []*CustomUser
models.NewQuery(
qm.Load(models.UserRels.Books), // this doesn't work
).Bind(ctx, db, *customUsers) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I don't think there's a way to do that, unfortunately. I've also tried and failed. As far as I can tell from the code, eager loading relationship requires that the base edit: right, it's callLoadFunction in eager_load.go that makes things go wrong when you do this. I guess you could possibly work around this by making your |
Beta Was this translation helpful? Give feedback.
-
Yeah, currently there's no way to achieve this nicely. It looks for the L struct and a function that does the eager loading on the generated model. If someone ever gets around to rewriting the eager loading stuff this could be a part of it maybe :D |
Beta Was this translation helpful? Give feedback.
-
Should work in |
Beta Was this translation helpful? Give feedback.
Should work in
v4.12.0+