Files
zod-backend/typeorm.cli.ts
Oracle Public Cloud User 05872b5170 feat:mvp1 initial commit
2024-11-21 06:07:08 +00:00

21 lines
618 B
TypeScript

import { NestFactory } from '@nestjs/core';
import { AppModule } from './src/app.module';
import { DataSource } from 'typeorm';
/**
* Getting data source through NestJS app helps in getting entities dynamically with "autoLoadEntities" NestJS feature
* as well as keeping migrations config in sync with what is configured in the app.
*/
async function getTypeOrmDataSource() {
process.env.MIGRATIONS_RUN = 'false';
const app = await NestFactory.createApplicationContext(AppModule);
const dataSource = app.get(DataSource);
await app.close();
return dataSource;
}
export default getTypeOrmDataSource();