Compare values in a Many2Many relationship #1855
Unanswered
NefixEstrada
asked this question in
Q&A
Replies: 1 comment
-
Hello, You could try something like this if err := db.Model(u).
Relation("Entities", func(q *orm.Query) (*orm.Query, error) {
q = q.Join("JOIN users AS user ON user.id = user_to_entity.user_id").
Where("user.gpu <= entity.gpu")
return q, nil
}).
Select(); err != nil {
panic(err)
} But overall pre-defined Relations are not very flexible and you should not rely on them to write custom queries. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
First of all we'd like to thank you for your hard work maintaining this awesome library!
We're trying to use
go-pg
for the new version of IsardVDI, but we don't know how to compare values in a Many2Many relationship. Given the following code:We know how to filter columns of each table:
But we can't find the way to compare
GPU
values between them, e.g.:This doesn't seem to work, is there a way or something that we're missing out?
Thanks a lot!
===============
Néfix Estrada
IsardVDI Developer
Beta Was this translation helpful? Give feedback.
All reactions