I am facing an issue with typeorm, where I have a queryBuilder
set up like this:
const projects = await this.conn.getRepository(UserProjectRelations).createQueryBuilder("userProject")
.innerJoin("userProject.userId", "user", "user.id = :userId", { userId: currentUser.id })
.leftJoinAndSelect("userProject.projectId", "project")
return await projects.getRawOne();
Why does this query output the following data:
RowDataPacket {
userProject_id: 67,
userProject_status: 'Owner',
userProject_lastUpdate: 2021-03-24T21:13:32.000Z,
project_id: 21,
project_name: 'nest',
project_appName: 'Test123!',
project_createdAt: 2021-03-24T20:47:40.000Z,
project_shortDescription: null,
}
Instead of the desired format:
{
userProject: {
"id":67,
"status":"Owner",
"lastUpdate":"..."
},
project: {
"name":"test",
"appName":"Test123!",
"createdAt": "..."
}
}
I would like to return nested objects without using aliases. Can anyone guide me on how to achieve this using the queryBuilder
?
Thank you in advance for any assistance!