Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import "reflect-metadata";
- import { createConnection, ConnectionManager, getConnectionManager } from "typeorm";
- export class Database {
- private connectionManager: ConnectionManager
- constructor() {
- console.log(`Database()`)
- this.connectionManager = getConnectionManager()
- }
- public async getConnection() {
- console.log(`Database.getConnection()`)
- try {
- return this.connectionManager.get()
- }
- catch (e) {
- console.warn(e)
- return createConnection({
- type: "postgres",
- host: "localhost",
- port: 5432,
- username: "postgres",
- database: "postgres",
- entities: [
- __dirname + "/entities/*.js"
- ],
- synchronize: true,
- logging: false
- })
- }
- }
- }
Add Comment
Please, Sign In to add comment