Skip to content

Commit

Permalink
fix: Use direct connections when connecting to local replicasets (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
hofmeister authored Jun 17, 2023
1 parent af1dc91 commit 97fdaf2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/MongoDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export abstract class MongoDB<T extends PrismaClient> {
}
}

const url = `mongodb://${credentials}@${this._dbInfo.host}:${this._dbInfo.port}/${this._dbName}?authSource=admin`;
const url = `mongodb://${credentials}@${this._dbInfo.host}:${this._dbInfo.port}/${this._dbName}?authSource=admin&directConnection=true`;
console.log('Connecting to mongodb database: %s', url);

this._prisma = this.createClient({
Expand Down
2 changes: 1 addition & 1 deletion src/cmd-database-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function resolveUrl(resourceName: string) {
}
}

return `mongodb://${credentials}@${dbInfo.host}:${dbInfo.port}/${dbName}?authSource=admin`;
return `mongodb://${credentials}@${dbInfo.host}:${dbInfo.port}/${dbName}?authSource=admin&directConnection=true`;
}

if (!process.argv[2]) {
Expand Down

0 comments on commit 97fdaf2

Please sign in to comment.