Connect Mongodb database using Node JS with express and mongoose tutorial

preview_player
Показать описание
How to connect local mongodb compass database with node js using express and mongoose packages is shown

#nodejs #mongodb
Рекомендации по теме
Комментарии
Автор

great video man !!! You explained really well

abhinavshukla
Автор

Thanks a lot for this short video! It is very precise and exactly what I wanted 💯💯💯💯💯

vedant
Автор

Thanks brother 😊 successfully connected.

nikhilkumarjha
Автор

Thanks for the video.Where is the next part as you mention in last ie create collection and compass and testing postman.i didnt seen that video in your playlist

shabeergect
Автор

Just an FYI, both options for the mongoose connect function are deprecated as of version 4.0.0.

ArthurLevitsky-cp
Автор

code works fine without any error bt when I check my database there is no new db created??why this happening ??I tried many methods and kind of fed up...

Riswanch
Автор

fix it, i am getting this error
(node:31652) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
(Use `node --trace-warnings ...` to show where the warning was created)

Travel-rikf
Автор

With yarn can u say
Yarn add express mongodb cors

vijayvodnala
Автор

here's the error :[nodemon] starting `node script.js`
Database connection error: connect ECONNREFUSED ::1:27017
Failed to connect to the database: connect ECONNREFUSED ::1:27017
[nodemon] clean exit - waiting for changes before restart

zanduop
Автор

i get this error, can u help me fix this? may god bless ur soul

MongoServerSelectionError: connect ECONNREFUSED ::1:27017

at listOnTimeout
at process.processTimers (node:internal/timers:512:7) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { 'localhost:27017' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined,
[Symbol(errorLabels)]: Set(0) {}
}

fadyghanem
Автор

MongooseServerSelectionError: connect ECONNREFUSED ::1:27017

soufianch
Автор

throw err;
^

Error: Cannot find module
at Module._resolveFilename
at Module._load
at [as runMain]
at {
code: 'MODULE_NOT_FOUND',
requireStack: []
}i am crying for 2 hrs help me solve this problem

dhruvgupta
Автор

on port 300e !!!

I

MongoParseError: Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://" at new ConnectionString

at parseOptions at new MongoClient

at

at new Promise (<anonymous>) at

at at promiseorCallback

at Mongoose.

at Mongoose.connect

gobinathreddy
Автор

I got this error
events.js:352
throw er; // Unhandled 'error' event
^

Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1320:16)
at listenInCluster (net.js:1368:12)
at Server.listen (net.js:1454:7)
at Function.listen
at Object.<anonymous>
at Module._compile
at Object.Module._extensions..js
at Module.load
at Function.Module._load
at [as runMain]
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1347:8)
at processTicksAndRejections {
code: 'EADDRINUSE',
errno: -4091,
syscall: 'listen',
address: '::',
port: 3000
}

muhtarmuhtar
Автор

I have this error: // mongoose 6.10.0

MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
at Connection.openUri (F:\learn mongodb and mongoos\mongoos
at F:\learn mongodb and mongoos\mongoos
at promiseOrCallback (F:\learn mongodb and mongoos\mongoos
at Mongoose._promiseOrCallback (F:\learn mongodb and mongoos\mongoos
at Mongoose.connect (F:\learn mongodb and mongoos\mongoos
at Object.<anonymous> (F:\learn mongodb and mongoos\mongoos cc\app.js:9:10)
at Module._compile at Module._extensions..js
at Module.load
at Module._load {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { 'localhost:27017' => [ServerDescription] }, stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}

amrwael
Автор

My Code:
Index.js:
const express=require("express");
const
const app=express();

mongoose.connect("mongodb://localhost:27017/Initiation", {
useNewUrlParser:true, useUnifiedTopology:true
}, (err)=>{
if (err) {
console.log("Error Occured")
} else {
console.log("successfully connected");
}
});

app.listen(3000, ()=>{
console.log("Listen to port : 3000");
})

Error got :
MongooseError: Mongoose.prototype.connect() no longer accepts a callback
at Mongoose.connect (f:\My VS Code
at Object.<anonymous> (f:\My VS Code
at Module._compile
at Module._extensions..js
at Module.load
at Module._load
at [as runMain]
at

monishmayekar