# UseConnection Decorator

Module
import { UseConnection } from "@tsed/typeorm"
Source/packages/typeorm/src/decorators/useConnection.ts

# Overview

function UseConnection(connection: string): Function;
Param Type Description
connection string The connection name of the database.

# Description

Configure the connection used by injector repository.

import {Injectable} from "@tsed/di";
import {UseConnection} from "@tsed/typeorm";

@Injectable()
export class MyService {
  constructor(UseConnection("db1") userRepositoryDb1: UserRepository,
              UseConnection("db2") userRepositoryDb2: UserRepository)

}
1
2
3
4
5
6
7
8
9

Other topics