data/database.js aktualisiert
This commit is contained in:
+2
-1
@@ -5,7 +5,7 @@ const dbUser = process.env.MONGODB_USERNAME;
|
||||
const dbPassword = process.env.MONGODB_PASSWORD;
|
||||
const dbName = process.env.MONGODB_DB_NAME;
|
||||
|
||||
const uri = `mongodb+srv://${dbUser}:${dbPassword}@${clusterAddress}/?retryWrites=true&w=majority`;
|
||||
const uri = `mongodb://${dbUser}:${dbPassword}@${clusterAddress}/?retryWrites=true&w=majority`;
|
||||
const client = new MongoClient(uri);
|
||||
|
||||
console.log('Trying to connect to db: ' + uri);
|
||||
@@ -15,6 +15,7 @@ try {
|
||||
await client.db(dbName).command({ ping: 1 });
|
||||
console.log('Connected successfully to server');
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
console.log('Connection failed.');
|
||||
await client.close();
|
||||
console.log('Connection closed.');
|
||||
|
||||
Reference in New Issue
Block a user