SHARE
TWEET

Untitled

a guest Sep 11th, 2019 160 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { createConnection } from 'typeorm';
  2. import { Entities } from '../entities/entities';
  3.  
  4. import { config } from './config';
  5.  
  6. export const databaseInitializer = async (): Promise<void> => {
  7.     return await createConnection({
  8.         type: 'postgres',
  9.         host: config.dbHost,
  10.         port: config.dbPort,
  11.         username: config.dbUsername,
  12.         password: config.dbPassword,
  13.         database: config.database,
  14.         entities: [Entities.user, Entities.card], <-- Qui dove voglio cambiare per non dover scrivere tutto ogni volta
  15.         logging: ['query', 'error'],
  16.         synchronize: true,
  17.     })
  18.         .then(async () => {
  19.             console.log(`Database connection established on port: ${config.dbPort}`);
  20.         })
  21.         .catch(error => console.log('Connection error: ', error));
  22. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top