Coder Social home page Coder Social logo

Comments (3)

picbenoit avatar picbenoit commented on April 27, 2024 33

After a lot of tries and checking TypeORM issues, I find a solution to my issue.

The name of the connection must be outside the useFactory, like this :

  SequelizeModule.forRootAsync({
    imports: [ConfigModule],
    // HERE
    name: 'heroku',
    useFactory: (configService: ConfigService) => ({
      // NOT HERE
      // name: 'heroku',
      dialect: 'postgres',
      host: configService.get<string>('heroku.host'),
      port: configService.get<number>('heroku.port'),
      username: configService.get<string>('heroku.user'),
      password: configService.get<string>('heroku.password'),
      database: configService.get<string>('heroku.database'),
      schema: configService.get<string>('heroku.schema'),
      autoLoadModels: true,
      synchronize: false,
    }),
    inject: [ConfigService],
  })

from sequelize.

kamilmysliwiec avatar kamilmysliwiec commented on April 27, 2024

Please provide a minimum reproduction repository.

from sequelize.

picbenoit avatar picbenoit commented on April 27, 2024

Hello @kamilmysliwiec

I thought I had put the essentials. Whick parts of code do you need more ?

I was a project with one connection worked well. I tried to put a new postgres connection whom I named heroku. The first one does not have name (default). I create a new module Accounts, with module, service and model files (module and service file are shown above).

I specify "heroku" connection for my account model :
SequelizeModule.forFeature([Account], 'heroku')

@InjectModel(Account, 'heroku')

And I finally obtain "Nest can't resolve dependencies of the AccountsService (?, heroku_AccountRepository). Please make sure that the argument herokuConnection at index [0] is available in the AccountsModule context."

If I do not put "heroku" connection parameter, my app is compiling.

from sequelize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.