How would I convert the code below to TypeORM querybuilder? I am trying to follow the documentation.
x
this.repository.manager.query(`
SELECT item.name, item.id
FROM item_location
INNER JOIN item ON item.id = item_location.itemId
WHERE item_location.locationId = ${queryObject.filter};
`)
Thanks.
Advertisement
Answer
I figured it out.
await getManager()
.createQueryBuilder(Item, 'item')
.select(['item.id', 'item.name'])
.innerJoin('item.location', 'location')
.where('location.id = :id', { id: queryObject.filter });