0
votes

is it possible to inject Tree Typeorm repository into Nestjs?

I didn't find anything online or in the sources that would help me here.

Or would it be better at this point to initialize nestjs and Typeorm seperat and not use the injection of nestjs and the TypeOrm module of Nestjs?

2

2 Answers

1
votes

I found the solution myself right after I posted this. :D You just have to inject the EntityManager with @InjectEntityManager() and then you can access .getTreeRepository().

1
votes

You can also do:

  constructor(@InjectRepository(Entity)
              private readonly treeRepository: TreeRepository<Entity>,
              ) {
  }

  async findAllNested(): Promise<Entity[]> {
    return await this.treeRepository.findTrees();
  }