-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1233 from nestjs/feat/typeorm-0.3-migration
feat(): support typeorm ^0.3.0 version
- Loading branch information
Showing
14 changed files
with
283 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
import { Inject } from '@nestjs/common'; | ||
import { Connection, ConnectionOptions } from 'typeorm'; | ||
import { DataSource, DataSourceOptions } from 'typeorm'; | ||
import { EntityClassOrSchema } from '../interfaces/entity-class-or-schema.type'; | ||
import { DEFAULT_CONNECTION_NAME } from '../typeorm.constants'; | ||
import { DEFAULT_DATA_SOURCE_NAME } from '../typeorm.constants'; | ||
import { | ||
getConnectionToken, | ||
getDataSourceToken, | ||
getEntityManagerToken, | ||
getRepositoryToken, | ||
} from './typeorm.utils'; | ||
|
||
export const InjectRepository = ( | ||
entity: EntityClassOrSchema, | ||
connection: string = DEFAULT_CONNECTION_NAME, | ||
): ReturnType<typeof Inject> => Inject(getRepositoryToken(entity, connection)); | ||
dataSource: string = DEFAULT_DATA_SOURCE_NAME, | ||
): ReturnType<typeof Inject> => Inject(getRepositoryToken(entity, dataSource)); | ||
|
||
export const InjectConnection: ( | ||
connection?: Connection | ConnectionOptions | string, | ||
export const InjectDataSource: ( | ||
dataSource?: DataSource | DataSourceOptions | string, | ||
) => ReturnType<typeof Inject> = ( | ||
connection?: Connection | ConnectionOptions | string, | ||
) => Inject(getConnectionToken(connection)); | ||
dataSource?: DataSource | DataSourceOptions | string, | ||
) => Inject(getDataSourceToken(dataSource)); | ||
|
||
/** @deprecated */ | ||
export const InjectConnection = InjectDataSource; | ||
|
||
export const InjectEntityManager: ( | ||
connection?: Connection | ConnectionOptions | string, | ||
dataSource?: DataSource | DataSourceOptions | string, | ||
) => ReturnType<typeof Inject> = ( | ||
connection?: Connection | ConnectionOptions | string, | ||
) => Inject(getEntityManagerToken(connection)); | ||
dataSource?: DataSource | DataSourceOptions | string, | ||
) => Inject(getEntityManagerToken(dataSource)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.