Skip to content

Commit

Permalink
mongodb plain connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Alloza committed Oct 4, 2024
1 parent 6f68b05 commit e6eb1a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion eda/eda_api/lib/module/excel/excel-sheet.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ export class ExcelSheetController {
const parsedUrl = new URL(databaseUrl?.url);
//Transformar a datasource con todo inicializado a vacio
const { host, port, password } = parsedUrl;

const config = {
type: "mongodb",
host: host.substring(0, host.indexOf(':')),
port: Number(port),
database: parsedUrl.pathname.substring(1),
user: parsedUrl.username,
password,
password: parsedUrl.password,
};

const mongoConnection = new MongoDBConnection(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export class MongoDBConnection extends AbstractConnection {
const user = this.config.user;
const password = this.config.password;

this.connectUrl = `${type}://${user}:${password}@${host}:${port}/${db}?authSource=${db}`;
let credentialStr = '';
if (user && password) {
credentialStr = `${user}:${password}@`;
}

this.connectUrl = `${type}://${credentialStr}${host}:${port}/${db}?authSource=${db}`;

const options = { useNewUrlParser: true, useUnifiedTopology: true };
const connection = await MongoClient.connect(this.connectUrl, options);
Expand Down

0 comments on commit e6eb1a8

Please sign in to comment.