Last active
September 2, 2018 14:48
-
-
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/
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
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