1var mongo = require('mongodb').MongoClient;
2
3async function connect(){
4 /**
5 * Connection URI. Update <username>, <password>, and <your-cluster-url> to reflect your cluster.
6 * See https://docs.mongodb.com/ecosystem/drivers/node/ for more details
7 */
8 const uri = "yourUri";
9
10
11 const client = new mongo(uri);
12
13 try {
14 // Connect to the MongoDB cluster
15 await client.connect();
16
17 // Make the appropriate DB calls
18 const db = client.db("testDatabase");
19
20 const collections = await db.collections();
21 collections.forEach (c=>console.log(c.collectionName));
22
23
24
25
26
27 } catch (e) {
28 console.error(e);
29 } finally {
30 await client.close();
31 }
32}
33
34connect().catch(console.error);
35
1async function connect(){
2 /**
3 * Connection URI. Update <username>, <password>, and <your-cluster-url> to reflect your cluster.
4 * See https://docs.mongodb.com/ecosystem/drivers/node/ for more details
5 */
6 const uri = "yourUri";
7
8
9 const client = new mongo(uri);
10
11 try {
12 // Connect to the MongoDB cluster
13 await client.connect();
14
15 // Make the appropriate DB calls
16 const db = client.db("testDatabase");
17
18 const collections = await db.collections();
19 collections.forEach (c=>console.log(c.collectionName));
20
21 }
22
23
24
25 // Make the appropriate DB calls
26
27
28 } catch (e) {
29 console.error(e);
30 } finally {
31 await client.close();
32 }
33}
34
35connect().catch(console.error);
36