const typeorm = require("typeorm");
const connectionManager = require("typeorm").getConnectionManager();
//const connectionManager = typeorm.getConnectionManager();
const connected = connectionManager.has("default");
if(!connected){
// ? load connection options from ormconfig or environment
//const connectionOptions = await getConnectionOptions();
connectionManager.create({
//name: "default",
type: "mysql",
// "extra": {
// "socketPath": "/cloudsql/ooxxooxx"
// },
host: "oo.xx.oo.xx",
port: 3306,
username: "root",
password: "ooxxooxx",
database: "ooxxdb",
synchronize: false,
logging: true, // this.env === 'dev' ? true : false
ssl: SSL,
keepConnectionAlive: false,
});
}
try {
db = connectionManager.get();
if(!connected){
await db.connect();
console.log('connect .... OK!');
}
}catch(error) {
console.log("TypeORM Error: ", error);
};
var ranks = await db.query("select * from users");