我如何将下面的代码转换为 TypeORM 查询生成器? 我正在尝试关注 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};
`)
谢谢。
最佳答案
我想通了。
await getManager()
.createQueryBuilder(Item, 'item')
.select(['item.id', 'item.name'])
.innerJoin('item.location', 'location')
.where('location.id = :id', { id: queryObject.filter });
关于sql - 如何将 SQL 语句转换为 TypeORM 查询生成器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48296623/