How would I convert the code below to TypeORM querybuilder? I am trying to follow the documentation.
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.
TypeORM is a TypeScript ORM (object-relational mapper) library that makes it easy to link your TypeScript application up to a relational database database. TypeORM supports MySQL, SQlite, Postgres, MS SQL Server, and a host of other traditional options.
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 });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With