nestjs / typeorm

TypeORM module for Nest framework (node.js) 🍇

Home Page:https://nestjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Repository] this.connection.createQueryRunner is not a function

matias-pg opened this issue · comments

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

A Repository receives a Connection instance that has the createQueryRunner function undefined, while a Service receives a Connection instance with that function defined.

Expected behavior

The Connection instance injected to the Repository should have that function defined too, to execute a transaction there and not inside a Service.

Minimal reproduction of the problem with instructions

See this repo.

What is the motivation / use case for changing the behavior?

It should be nice to have all the database-related code in the Repository, and use the Service for other stuff like validation.

Environment


Nest version: 7.1.5

 
For Tooling issues:
- Node version: 12.16.3  
- Platform: Linux 

Others:

I'm using:
- Docker
- Database: tested with MariaDB and PostgreSQL
- VS Code
- NPM

Thanks! That fixed it.

I sent a small change to the documentation to mention that custom repositories need to inject EntityManager instead of Connection (like services do). Might it be necesary to mention it?

I think I have the same issue, here the details.

I read this thread and the other but I didn't understand how to fix my issue. :D

Some help?