nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.08k stars 7.56k forks source link

TypeOrm throwing transaction error when seeding #103

Closed Kiho closed 7 years ago

Kiho commented 7 years ago

I have some conversation in nest-typeorm-example here about the issue. Basically nest throwing connection error if the code try connecting to DB before the first call is resolved. I made work-around but I think I need more solid resolution.

cojack commented 7 years ago

@Kiho please check issue #86 and I have made some improvements for async onModuleInit you could check the #100 maybe it will fit for you

Kiho commented 7 years ago

@cojack Initially, I think it's just problem with lazy loading but now I need more than that to switching out C# to Node Back-End. That's what I am evaluating these days. My requirement here is I like to have generic controller to handle most of CRUD operation. Additionally, if I need to handle more complex scenario then create new controller for given entity. I made POC on this subject in the repo here. You can see my main issue in this file service.registry.ts. I thinks I am missing 2 things here.

  1. Batch registration of components - I like to register all of the services by naming convention to be available as component. Like to register entities in this module database.config.ts
  2. Dependency Injection other than constructor - Expose container to be accessible in client code.
    const services = [
     container.GetInstance<DepartmentService>(),
     container.GetInstance<EmployeeService>(),
     container.GetInstance<UserService>()
    ];
kamilmysliwiec commented 7 years ago

Hi @Kiho, Take a look on my latest answer here https://github.com/kamilmysliwiec/nest/issues/86.

kamilmysliwiec commented 7 years ago

Hi @Kiho, Please, take a look here http://www.docs.nestjs.com/recipes/sql-typeorm :cat: Thanks, Kamil

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.