How to use the getConnectionManager function from typeorm

Find comprehensive JavaScript typeorm.getConnectionManager code examples handpicked from public code repositorys.

40
41
42
43
44
45
46
47
48
49
                cfg.entities[i] = Util.getAbsPath([item]);
            }
        });
    }
    const {getConnectionManager} = require('typeorm');
    this.connection = getConnectionManager().create(cfg);
}

/**
 * 获取连接
fork icon7
star icon52
watch icon3

57
58
59
60
61
62
63
64
65
66
}

function getDatabaseConnection() {
  try {
    ormConfig.name = 'seed-connection'; // to avoid using the 'default' connection
    const connectionManager = typeorm.getConnectionManager();
    return connectionManager.has(ormConfig.name) ? connectionManager.get(ormConfig.name) : connectionManager.create(ormConfig);
  } catch (error) {
    console.log('Cannot find ormconfig.js');
    throw error;
fork icon0
star icon6
watch icon4

+ 15 other calls in file

9
10
11
12
13
14
15
16
17
18
  logType = ['error', 'warn'];
} else {
  logType = ['error'];
}

const pool = getConnectionManager().create({
  name: 'default',
  type: process.env.DB_CONNECTION,
  host: process.env.DB_HOST,
  port: process.env.DB_PORT,
fork icon3
star icon2
watch icon4