Connect NodeJs with MongoDB local device
const {MongoClient} = require('mongodb');
const database = 'Class12';
const url = 'mongodb://0.0.0.0:27017';
const client = new MongoClient(url);
async function getdata(){
let result = await client.connect();
let db = result.db(database);
let collection = db.collection('students');
let response = await collection.find({}).toArray();
console.log(response);
}
getdata();
Comments
Post a Comment