Node JS Tutorial in Hindi #60 Connect MongoDB Atlas with Node.js
Connect Mongodb Atlas with Node js
Points of this video
- Check Connect method.
- Setup connect in node js.
- Write code for connection.
- Test connection and Data
- Interview Questions Notes,
- Code and playlist.
code of index.js file
import { MongoClient } from "mongodb";
const url="mongodb+srv://webanilsidhu:GoogleTest@cluster0.dqwwk5n.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0";
const database="school";
const collection="student";
const client= new MongoClient(url);
client.connect().then(()=>{
console.log(".......connect..........");
})
async function dbConnection(){
const db= client.db(database)
const collectResult = db.collection(collection);
const result = await collectResult.find().toArray();
console.log(result);
}
dbConnection()
Github Link :- https://github.com/anil-sidhu/node-express-mongodb/tree/mongodb-atlas