Skip to content

Instantly share code, notes, and snippets.

@kerren
Last active September 2, 2018 14:48
Show Gist options
  • Save kerren/8ed372fcfa96572fe6f13a997ada35cc to your computer and use it in GitHub Desktop.
Save kerren/8ed372fcfa96572fe6f13a997ada35cc to your computer and use it in GitHub Desktop.
The database connections array for Nest.js - https://blog.entrostat.com/setting-up-a-database-module-in-nest-js/
import { TypeOrmModule } from '@nestjs/typeorm';
import { Config } from '../shared/config/config';
import * as appRootPath from 'app-root-path';
import * as path from 'path';
export const databaseConnections = [
TypeOrmModule.forRoot({
type: 'postgres',
host: Config.get.databases.main.host,
port: Config.get.databases.main.port,
username: Config.get.databases.main.username,
password: Config.get.databases.main.password,
database: Config.get.databases.main.database,
name: Config.get.databases.main.name,
entities: [
// Add the paths to modules that use the main database here
`${path.join(appRootPath.path, 'src', 'modules', 'shared')}/**/*.entity{.ts,.js}`
],
synchronize: true
})
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment