How to run custom query on relation ? #1907
Unanswered
palashjain95
asked this question in
Q&A
Replies: 0 comments
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.
-
I have a relation on which I want to run a custom query
Custom query
select *
from (
select
*,
row_number() over (partition by col1,col2 order by col3 desc)
as row_number
from table
) temp where row_number=1;
Following is my code
query := dbConnection.Model(records)
query.Relation("States", func(q *orm.Query) (*orm.Query, error) {
return , nil
})
Option 1: is there some way to write custom query inside the internal function in query.Relation
Option 2: is there some way in which we can write this custom query in orm
Beta Was this translation helpful? Give feedback.
All reactions