marriedtermiteblyi commited on
Commit
daf2aa2
·
verified ·
1 Parent(s): dfb7875

put notes/c0796331-1e39-4972-97dc-924c912417ff.json

Browse files
notes/c0796331-1e39-4972-97dc-924c912417ff.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "c0796331-1e39-4972-97dc-924c912417ff",
3
+ "title": "Untitled",
4
+ "content": "const { MongoClient } = require('mongodb');\n\n// Replace with your actual connection string (Atlas or Local)\nconst uri = \"mongodb+srv://admin:Tuan2007@cluster0.c7li2xx.mongodb.net/?appName=Cluster0\";\n\nconst client = new MongoClient(uri);\n\nasync function connectDB() {\n try {\n // Connect to the MongoDB cluster\n await client.connect();\n console.log(\"Successfully connected to MongoDB!\");\n\n // Access a specific database\n const db = client.db('myDatabase');\n // Do something...\n\n } catch (error) {\n console.error(\"Connection error:\", error);\n } finally {\n // Keep connection open for the app lifecycle, or close if it's a one-off script\n // await client.close();\n }\n}\n\nconnectDB();",
5
+ "language": "javascript",
6
+ "createdAt": 1776171355918,
7
+ "updatedAt": 1776171355918
8
+ }