📜  不同的数据库连接取决于 typeorm 中的环境 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:21.029000             🧑  作者: Mango

代码示例1
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',
  },
};