Typeorm-How-to Write-to-Different-Databases

// src/index.ts
    await createConnection({
      name: 'connection1',
      host: 'SERVER1',
      username: 'bob',
      password: 'xxx',
      type: 'mssql',
      database: 'db1',
      synchronize: true,
      entities: ['src/entity/**/*.ts'],
      migrations: ['src/migration/**/*.ts'],
      subscribers: ['src/subscriber/**/*.ts'],
      cli: {
        entitiesDir: 'src/entity',
        migrationsDir: 'src/migration',
        subscribersDir: 'src/subscriber',
      },
    })

    await createConnection({
      name: 'connection2',
      host: 'SERVER2',
      username: 'mike',
      password: 'xxx',
      type: 'mssql',
      database: 'db2',
      synchronize: true,
      entities: ['src/entity/**/*.ts'],
      migrations: ['src/migration/**/*.ts'],
      subscribers: ['src/subscriber/**/*.ts'],
      cli: {
        entitiesDir: 'src/entity',
        migrationsDir: 'src/migration',
        subscribersDir: 'src/subscriber',
      },
    })
Restu Wahyu Saputra