Is there a way to retrieve a list of objects with a OneToMany relation using TypeORM's queryBuilder?
This is the desired output:
{
"id": 1,
"firstName": "Bob",
"lastName": "Sparrow",
"orders": [
{
"id": 1,
"name": "Very Big Order"
},
{
"id": 2,
"name": "Big F*** Order"
}
]
}
I attempted the following approach:
const user = await this.conn
.getRepository(User)
.createQueryBuilder("user")
.leftJoin("user.orders", "orders")
.select("user.orders", "orders")
.getRawMany();
Unfortunately, this does not return an array of all objects :/