This commit is contained in:
Erik 2022-08-31 23:19:34 +03:00
parent d4ab0ff66d
commit 0cdef2db8b
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -11,10 +11,10 @@ class MongoDBProvider extends Provider {
});
const { MONGODB_HOST, MONGODB_USERNAME, MONGODB_PASSWORD, MONGODB_DATABASE } = process.env;
const database = MONGODB_DATABASE;
this.database = MONGODB_DATABASE;
// const { database } = this.config;
const auth = MONGODB_USERNAME ? `${MONGODB_USERNAME}:${MONGODB_PASSWORD}@`:'';
this.URI = `mongodb://${auth}${MONGODB_HOST}/${database}?authSource=${database}`;
this.URI = `mongodb://${auth}${MONGODB_HOST}/${this.database}?authSource=${this.database}`;
}
@ -22,7 +22,7 @@ class MongoDBProvider extends Provider {
try {
this.connection = await MongoClient.connect(this.URI, { useNewUrlParser: true });
this.db = await this.connection.db(this.config.database);
this.db = await this.connection.db(this.database);
return this._initialized = true; //eslint-disable-line no-return-assign
} catch (err) {
this._error(err);