How to join one to many relationship using db.select api and get nested array in result #2228
Unanswered
shellking4
asked this question in
Q&A
Replies: 1 comment
-
I could not succeed and plan to change from mariadb to mysql just to be able to user query syntax to get this nested object. It's very convenient for JS devs. |
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
-
So let's suppose I have tables users and posts where a user owns many posts
How to retrieve a user with his posts using db.select and get back a result like
[
{ userId: "sjvhbdsh", posts: [ {"postId": "sdbdjvbsjbv"} ] }
]
And this without any js transformatio, just with specifying fields in the select method
Beta Was this translation helpful? Give feedback.
All reactions