typeorm#ConnectionOptionsReader TypeScript Examples
The following examples show how to use
typeorm#ConnectionOptionsReader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: typeorm-uml.class.ts From typeorm-uml with MIT License | 6 votes |
/**
* Creates and returns Typeorm connection based on selected configuration file.
*
* @async
* @private
* @param {string} configPath A path to Typeorm config file.
* @param {Flags} flags An object with command flags.
* @returns {Connection} A connection instance.
*/
private async getConnection( configPath: string, flags: Flags ): Promise<Connection> {
let root = process.cwd();
let configName = configPath;
if ( isAbsolute( configName ) ) {
root = dirname( configName );
configName = basename( configName );
}
const cwd = dirname( resolve( root, configName ) );
process.chdir( cwd );
const connectionOptionsReader = new ConnectionOptionsReader( { root, configName } );
const connectionOptions = await connectionOptionsReader.get( flags.connection || 'default' );
return getConnectionManager().create( connectionOptions );
}
Example #2
Source File: module.ts From typeorm-extension with MIT License | 6 votes |
/**
* Build DataSourceOptions from configuration.
*
* @deprecated
* @param context
*/
export async function buildLegacyDataSourceOptions(
context: DataSourceOptionsBuildContext,
) : Promise<DataSourceOptions> {
const directory : string = context.directory || process.cwd();
const tsconfigDirectory : string = context.tsconfigDirectory || process.cwd();
const connectionOptionsReader = new ConnectionOptionsReader({
root: directory,
configName: context.configName,
});
const dataSourceOptions = await connectionOptionsReader.get(context.name || 'default');
return extendDataSourceOptions(dataSourceOptions, tsconfigDirectory);
}