skip to Main Content

Unable to update a course by its id using mongoDB and mongoose in noddejs

const mongoose = require('mongoose'); mongoose.connect("mongodb://localhost:27017/mongo-exercise") .then( ()=> console.log("Connected to MongoDB...")) .catch(err => console.error("Failed to connect to db...",err)); Below is the course schema and model const courseSchema = new mongoose.Schema({ name:String, author:String, tags:[String], date:Date, isPublished: Boolean, price:Number }); const Course =…

VIEW QUESTION

Javascript – MongoDB ECCONREFUSED when connecting to MongoDB Compass

I am trying to learn Node.JS from scratch. I am trying to connect index.js to MongoDB compass when I get the error: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 at _handleConnectionErrors (/mnt/c/Users/user/Desktop/Programming/website/learningNode/mongoose/node_modules/mongoose/lib/connection.js:897:11) at NativeConnection.openUri (/mnt/c/Users/user/Desktop/Programming/website/learningNode/mongoose/node_modules/mongoose/lib/connection.js:848:11) { reason: TopologyDescription { type: 'Unknown', servers: Map(1)…

VIEW QUESTION
Back To Top
Search