Skip to content

Commit

Permalink
fix: incorrect connection url
Browse files Browse the repository at this point in the history
- handle multiple host and port
- add /db name after all host:port
  • Loading branch information
Chinlinlee committed Feb 4, 2022
1 parent 824bdfb commit 2348a08
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion models/mongodb/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ module.exports = exports = function (config) {
if (index == 0) {
databaseUrl += `mongodb://${host}:${ports[0]}`;
} else {
databaseUrl += `,${dbName}`;
databaseUrl += `,${host}:${ports[index]}`;
}
});
databaseUrl += `/${dbName}`;

console.log(databaseUrl);
mongoose.connect(databaseUrl, {
Expand Down

0 comments on commit 2348a08

Please sign in to comment.