@nestjs/typeorm#TypeOrmOptionsFactory TypeScript Examples
The following examples show how to use
@nestjs/typeorm#TypeOrmOptionsFactory.
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: ormconfig.service.ts From nestjs-api-example with MIT License | 6 votes |
@Injectable()
export class TypeOrmConfigService implements TypeOrmOptionsFactory {
constructor(private configService: ConfigService) {}
createTypeOrmOptions(): TypeOrmModuleOptions {
return {
type: this.configService.get('DB_TYPE') as any,
host: this.configService.get('DB_HOST'),
port: parseInt(this.configService.get('DB_PORT')) || 3306,
username: this.configService.get('DB_USERNAME'),
password: this.configService.get('DB_PASSWORD'),
database: this.configService.get('DB_NAME'),
entities: [__dirname + '/../../**/*.entity{.ts,.js}'],
synchronize: this.configService.isEnv('development'),
logging: this.configService.isEnv('development'),
};
}
}
Example #2
Source File: user.e2e-spec.ts From nestjs-api-example with MIT License | 6 votes |
class MockTypeOrmConfigServer implements TypeOrmOptionsFactory {
createTypeOrmOptions(): TypeOrmModuleOptions {
return {
type: 'sqlite',
database: ':memory:',
synchronize: true,
dropSchema: true,
entities: ['src/api/**/*.entity.ts'],
};
}
}