-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
26 lines (21 loc) · 815 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const { MongoClient, ServerApiVersion } = require('mongodb');
async function main() {
const uri = "mongodb+srv://6420015:[email protected]/?retryWrites=true&w=majority&appName=ClusterAF";
const client = new MongoClient(uri, {
serverApi: ServerApiVersion.v1,
connectTimeoutMS: 10000, // 10-second timeout
});
try {
await client.connect();
console.log('Connected to MongoDB');
const db = client.db('afterfall');
console.log('Connected to database');
const usersCollection = db.collection('users');
console.log('Connected to Users collection');
} catch (err) {
console.error('Error connecting to MongoDB:', err);
} finally {
await client.close();
}
}
main().catch(console.error);