Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

different db connectons depending on env in typeorm

require('dotenv/config');


const database = {
  development: "dev-db",
  production: 'prod-db',
  test: 'test-db'
}

module.exports = {
  type: 'postgres',
  host: 'localhost',
  port: 5432,
  username: 'ur-username',
  password: 'password',
  database: database[process.env.NODE_ENV],
  entities: ['dist/**/*.entity{.ts,.js}'],
  synchronize: true,
  migrationsTableName: 'migration',
  migrations: ['migration/*.js'],
  cli: {
    migrationsDir: 'migration',
  },
};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #db #connectons #depending #env #typeorm
ADD COMMENT
Topic
Name
8+4 =