const { MongoClient } = require('mongodb') // Create Instance of MongoClient for mongodb //const client = new MongoClient('mongodb+srv://gayatriparekh:gayu@211@cluster0.9fplife.mongodb.net/') //const client =new MongoClient('mongodb+srv://gayatriparekh:gayu@211@cluster0.9fplife.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0') const client=new MongoClient('mongodb+srv://gayatriparekh:gayu%40211@cluster0.9fplife.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0') // Connect to database client.connect() .then(() => console.log('Connected Successfully')) .catch(error => console.log('Failed to connect', error)) // Insert to database client.db('gkdbase').collection('testcol').insertOne({ name: 'Shreya Kapadia', email: 'shreyakapadia@gmail.com' }) .then((res) => { console.log(res) client.close() }) .catch((err) => console.log(err))