# 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
2
3
4
5
6
7
8
9
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Jest
- Seq
- Controllers
- Providers
- Model
- Converters
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing