Node js connect with MongoDB
index.js:
const express=require('express');
const app=express();
const mongoose=require('mongoose');
const connectDB=async()=>{
mongoose.connect('mongodb://localhost:27017/e-Comm');
const productSchema=new mongoose.Schema({});
const products=mongoose.model('products', productSchema)
const data=await products.find();
console.warn(data);
}
connectDB();
app.listen(5000);
Comments
Post a Comment