This is my configuration file of my API connections
const mysql = require("mysql");
const pool = mysql.createPool({
connectionLimit: 10,
user: user1,
password: 123456,
database: database1,
host: host1.server.com,
port: 3306,
});
exports.pool = pool;
What I need is for my API to connect to more than one server, where the databases are. How can be?
I tried it like this and it didn't work:
const mysql = require("mysql");
const pool1 = mysql.createPool({
connectionLimit: 10,
user: user1,
password: 123456,
database: database1,
host: host1.server.com,
port: 3306,
});
const pool2 = mysql.createPool({
connectionLimit: 10,
user: user2,
password: 123456,
database: database2,
host: host2.server.com,
port: 3306,
});
exports.pool = { pool1, pool2};
Can someone help me?