小编mle*_*eko的帖子

typeorm - InsertQueryBuilderCls 不是构造函数

我使用实体管理器进行事务,确保我像这样调用的过程中没有嵌套提交,我设置了 ,search_path 因为我的过程在内部调用无前缀实体

async savetournamentTransaction(tournament: any, matchId: string) {
    await this.connection.manager.transaction(async (tournamentEntityManager) => {
      const tournamentRepository = tournamentEntityManager.getRepository(tournament);
      await tournamentRepository.query(`SET LOCAL search_path to ${matchId}`);
      await tournamentRepository.save(tournament);
      await tournamentRepository.query(
        `CALL fillOrganizationScheduleTable($1,${tournament.tournament_id});`,
        [matchId],
      );
    });
  }
}
Run Code Online (Sandbox Code Playgroud)

然而,typeorm 给了我这个我无法真正理解的错误:

[Nest] 790  - 09/16/2022, 4:40:43 PM   ERROR [ExceptionsHandler] InsertQueryBuilderCls is not a constructor
TypeError: InsertQueryBuilderCls is not a constructor
    at SelectQueryBuilder.insert (/mypath/desktop/prj/volleyball-organization/src/query-builder/QueryBuilder.ts:200:16)
    at SubjectExecutor.executeInsertOperations (/mypath/desktop/prj/volleyball-organization/src/persistence/SubjectExecutor.ts:430:26)
    at SubjectExecutor.execute (/mypath/desktop/prj/volleyball-organization/src/persistence/SubjectExecutor.ts:137:20)
    at EntityPersistExecutor.execute (/mypath/desktop/prj/volleyball-organization/src/persistence/EntityPersistExecutor.ts:194:36)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at /mypath/desktop/prj/volleyball-organization/src/tournaments/tournaments.service.ts:155:13
    at EntityManager.transaction (/mypath/desktop/prj/volleyball-organization/src/entity-manager/EntityManager.ts:151:28)
    at tournamentsService.savetournamentTransaction (/mypath/desktop/prj/volleyball-organization/src/tournaments/tournaments.service.ts:152:9) …
Run Code Online (Sandbox Code Playgroud)

nestjs node.js-typeorm

7
推荐指数
2
解决办法
1102
查看次数

标签 统计

nestjs ×1

node.js-typeorm ×1