How to create a connection with mongoose in node js. ?

Here, we will write a program to establish connection with mongoose in node js. For this we will create a file app.js and require the necessary library. We also need to create a user in mongoose.

app.js

const mongoose=require('mongoose');

 mongoose.connect("mongodb://user:admin1234@cluster0.a4n6k.mongodb.net/userdemo?retryWrites=true&w=majority",
 {
    useNewUrlParser:true,
    useUnifiedTopology:true})
 //node src/app.js
.then(()=>console.log("connection successfully.."))
.catch((err)=>console.log(err));