我正在尝试使用TypeORM querybuilder的一些东西 . 但是在运行下面显示的代码后,我不断收到错误
(node:25699) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: Cannot use a pool after calling end on the pool
如果我首先添加 user
关系或 location
关系是重要的,因为首先添加的关系会按预期添加为关系 . 之后的那个一直在抛出错误 .
userIds.forEach(async (userId, i) => {
await getConnection()
.createQueryBuilder()
.relation(Pin, "user")
.of(pinIds[i])
.set(userId);
await getConnection()
.createQueryBuilder()
.relation(Pin, "location")
.of(pinIds[i])
.set(locationIds[i]);
});
1 回答
我通过仅创建一次连接并与该连接 Build 关系来解决问题 .