javascript - 具有嵌套关系的 TypeORM findOne
问题描述
我在使用 TypeORM 执行嵌套查找查询时遇到一些问题。这是基本代码:
const { completionId } = req?.params;
const user = req.user;
const retrievedCompletion = await getRepository(
CompletionGoogleSearch
).findOne({
relations: ['run', 'run.user'],
where: {
id: completionId,
// run: { user: { id: user.id } }, // This is the code that breaks the function
},
});
console.log(retrievedCompletion?.run.user.id);
console.log(user.id);
在我看来,一切正常,查询应该运行。知道我做错了什么吗?我知道我可以通过编写查询构建器查询或使用原始 SQL 来解决这个问题——我只是想知道我的代码是否存在缺陷。
解决方案
typeorm 尚不支持您询问的功能(2021 年 2 月)。
查看 2018 年开放的这个问题。
推荐阅读
- wso2 - 仍然可重现:未发现此服务器中部署的工件。忽略碳应用
- javafx - 检测到 DragOver 事件时使用哪个 CSS 选择器?
- ruby - 清理 URL 字符串
- javascript - 如何将字符串转换为blob?
- html - 如何在 Bootstrap 3 输入组中使按钮全宽?
- postgresql - 如何提高具有多个连接的写入繁重视图的查询速度?
- java - Osmosis WayNode 实例总是从 getLatitude 和 getLongitude 返回 0
- java - Maven 在命令提示符中工作,但在 Power Shell 中不工作
- rxjs - 如何在发出某些类型的事件时*保持订阅状态?
- powershell - 用前导 0 填充 IP 地址 - powershell