-
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.
feat(): support typeorm ^0.3.0 version
- Loading branch information
1 parent
5cb9cbf
commit 9001b56
Showing
14 changed files
with
235 additions
and
290 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,26 @@ | ||
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)); | ||
|
||
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.
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
Oops, something went wrong.