Known work-arounds for custom repositories inside a transaction?
ortonomy opened this issue · comments
I cannot find a way to make custom repositories work inside a transaction.
Since v9.0.0 of @nestjs/typeorm and v0.3.0 of typeorm you can not create custom repositories with class style, like it showed below:
this notice says it's not possible I think - but I can't be sure if it's not be done elsewhere? Do you know of any solution?
@alphamikle - thanks for responding so quickly on the other PR that isn't built. Are you able to offer any ideas here
I don't have that problem in front of me now, so I'm not concerned about finding a solution.
@alphamikle - you mean you don't see the problem when you use nest transact, or you don't have time?
Did you try some solutions from this typeorm/typeorm#9013?
yes, all of them. We get the is not a function
error when using withTransaction
You can close this @alphamikle - we've given up on nest transact unfortunately. Whilst the last update fixed the issue with circular dependencies, there is also a bug where repositories cannot be resolved with an injected service calls another service and that service has a repository.
Keep getting "Nest cannot resolve Repository element..." and can't find a way to resolve it. Resorted to a method on service to set the entity manager of an inject repository explicitly from outside the service before calling them. It's not elegant or great, but we need to move forward.
I don't have that problem in front of me now, so I'm not concerned about finding a solution.
@alphamikle - you mean you don't see the problem when you use nest transact, or you don't have time?
Did you try some solutions from this typeorm/typeorm#9013?
yes, all of them. We get the
is not a function
error when usingwithTransaction
For now, I'm mostly focused on Flutter development and touch Node / Nest very rarely, and because of that, I don't write backend code and custom repos 😀
There are two options which I would use myself if I had to solve this problem:
- Do not use custom repos and move custom repo` methods to service
- Fork typeorm and add to there the old class-based API to restore functionality and would made a PR to their repo, and would gather as many people as possible to support this PR, so that the maintainers would have no choice but to leave support for this API as well.
You can close this @alphamikle - we've given up on nest transact unfortunately. Whilst the last update fixed the issue with circular dependencies, there is also a bug where repositories cannot be resolved with an injected service calls another service and that service has a repository.
Keep getting "Nest cannot resolve Repository element..." and can't find a way to resolve it. Resorted to a method on service to set the entity manager of an inject repository explicitly from outside the service before calling them. It's not elegant or great, but we need to move forward.
Sad to hear that, but if it is the best decision - so be it. Unfortunately, I have no time, for now, to fix all the problems which have nest-transact
users. Maybe someone someday will fix them, maybe it would be me. But not in the next several months 😔