How to query and convert data to struct with foreign keys as inner struct? #1253
Unanswered
kyleerhabor
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
-
I'm developing a web API and using this library to make structured queries and responses.
I have a
users
table defined as so:For the
avatar_id
column, theimages
table is defined as so:In my source code, I'd use the
query_file_as!
macro to return an instance of myUser
struct conforming to theusers
table structure. The issue I want to address is with theavatar_id
column.Instead of returning the image ID, I'd like to return my
Image
struct. This would allow the user to request the user and have the avatar image data rather than making a subsequent request for the image data. Is there a way to implement this? If I were to write an SQL query, I could use anINNER JOIN
.Beta Was this translation helpful? Give feedback.
All reactions