Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { createConnection } from 'typeorm';
- import { Entities } from '../entities/entities';
- import { config } from './config';
- export const databaseInitializer = async (): Promise<void> => {
- return await createConnection({
- type: 'postgres',
- host: config.dbHost,
- port: config.dbPort,
- username: config.dbUsername,
- password: config.dbPassword,
- database: config.database,
- entities: [Entities.user, Entities.card], <-- Qui dove voglio cambiare per non dover scrivere tutto ogni volta
- logging: ['query', 'error'],
- synchronize: true,
- })
- .then(async () => {
- console.log(`Database connection established on port: ${config.dbPort}`);
- })
- .catch(error => console.log('Connection error: ', error));
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement