#Even if I Tell the Connection Name of Data Base, the Sequlize Still Use the Default Connection

4 messages · Page 1 of 1 (latest)

stuck caveBOT
#

Suggestion for @ocean prairie:
:warning: Please do not screenshot code as it causes a number of issues:

  • Ease of assistance: if someone wants to copy your code and correct it, they cannot. Making it easy for people to help you is in your best interests.
  • Editorializing: it's common to try to make images small, which means you're likely to crop out code relevant to your issue
  • Accessibility: wide images can be hard to read on mobile devices, and are impossible for screen readers.
  • Legibility: you cannot read screenshots of code directly, instead you have to open them in an enlarged context.
  • Bandwidth usage/clutter: some of our members use metered connections, and it is wasteful for them to download images of a text.

For a small amount of code, please use a code-block.

ocean prairie
#

I set the connction in both @SequelizeModule.forFeature and @InjectMode, but it still use the default datbase connection
Could anybody help me or give me an exmaple wiht sequlize and aultiple databases? Thank you!

#
@Module({
  imports: [
    SequelizeModule.forRoot({
      dialect: 'sqlite',
      storage: './db/iot-test.db',
      autoLoadModels: true,
      synchronize: false,
    }),
    SequelizeModule.forRoot({
      name: 'test2',
      dialect: 'sqlite',
      storage: './db/iot-test2.db',
      models: [Device, ReceiveMessageTest],
    }),
  ],
})
export class AppModule {}
#
@Module({
  imports: [SequelizeModule.forFeature([Device], 'test2')],
  controllers: [DeviceController],
  providers: [DeviceService],
})
export class DeviceModule {}