NodeJs — Connecting to MongoDB
MongoDB is a popular NoSQL database often used with Node.js. You can connect to it using the Mongoose library, which provides a schema-based solution to model your data.
npm install mongoose
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/mydb')
.then(() => console.log('Connected to MongoDB'))
.catch(err => console.error(err));