Skip to content

How can i define a model that queries from a function? #616

Answered by vmihailenco
nicerobot asked this question in Q&A
Discussion options

You must be logged in to vote

You can use a raw query and scan into a struct

type Model struct {...}

dest := new(Model)
db.Raw("select * from some_function()").Scan(ctx, dest)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nicerobot
Comment options

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

This discussion was converted from issue #615 on July 16, 2022 06:54.