Skip to content

Commit

Permalink
fix: use host if hostReplicaSet is not provided in MongoDriver (#…
Browse files Browse the repository at this point in the history
…7559)

Co-authored-by: mosman <mohamed_osman@unitedsolutions.biz>
  • Loading branch information
NthMetal and mosman committed May 29, 2021
1 parent 545a443 commit 9b6d7bc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/driver/mongodb/MongoDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,13 @@ export class MongoDriver implements Driver {
: "";

let connectionString = undefined;
const portUrlPart = (schemaUrlPart === "mongodb+srv")
? ""
: `:${options.port || "27017"}`;

if(options.replicaSet) {
connectionString = `${schemaUrlPart}://${credentialsUrlPart}${options.hostReplicaSet}/${options.database || ""}`;
connectionString = `${schemaUrlPart}://${credentialsUrlPart}${options.hostReplicaSet || options.host + portUrlPart || "127.0.0.1" + portUrlPart}/${options.database || ""}`;
} else {
const portUrlPart = (schemaUrlPart === "mongodb+srv")
? ""
: `:${options.port || "27017"}`;
connectionString = `${schemaUrlPart}://${credentialsUrlPart}${options.host || "127.0.0.1"}${portUrlPart}/${options.database || ""}`;
}

Expand Down

0 comments on commit 9b6d7bc

Please sign in to comment.