I have a table for posts where postedBy column have relation with id from profiles table. When I am joining the tables I am getting flat object for joined data like below.
{
id : 1,
postContent: "This is a post",
postImgUrl: "https://via.placeholder.com/150",
name : "User",
email : "user@email.com"
}
Result I want :
{
id : 1,
postContent: "This is a post",
postImgUrl: "https://via.placeholder.com/150",
postedBy : {
name : "User",
email : "user@email.com"
}
}
Posts Table
| id | postContent | postImgUrl | postedBy |
|---|---|---|---|
| 1 | row | https://via.placeholder.com/150 | U1 |
Users Table
| id | name | |
|---|---|---|
| U1 | User | user@email.com |