How to Connect Node.JS with MongoDB using Mongoose | Connect to a MongoDB Database Using Node.js

  Рет қаралды 197,751

Code With Yousaf

Code With Yousaf

Күн бұрын

Пікірлер: 62
@ricardopiedade9346
@ricardopiedade9346 Жыл бұрын
Man, I was stuck and you set me free...now I can go on with my course!! Thanks a Lot!
@krishr8599
@krishr8599 6 ай бұрын
bro which courese are you following bro and hwat are you doing now bro
@DIVESHCSC
@DIVESHCSC 5 ай бұрын
what course are you going with bro
@SearchAndSolve12345
@SearchAndSolve12345 10 ай бұрын
Weldon bro success connection ❤❤❤❤
@jamesbienaime8790
@jamesbienaime8790 Жыл бұрын
Great video but if you are getting the "Cannot Get error" after running node, I solved it by removing the getUsers from line 14. function since we are not using routing, simply replace it with '/' should get the code working.
@jetlinkarkha9659
@jetlinkarkha9659 11 ай бұрын
When I run I got syntax error said option.? session so what should I do. I am using nodejs version 12 and mongodb 7.0
@iamtiller7752
@iamtiller7752 Жыл бұрын
Thank you, I've been trying to connect mongodb locally and I was getting issues connecting, not knowing the url port should not be localhost
@pritam7461
@pritam7461 Жыл бұрын
hey the url that was used in this video can I use it or I have to select some other URL addr?
@catharinnivitha7587
@catharinnivitha7587 4 ай бұрын
Thanks a lot for the video! I was stuck in it for a long time
@Elizabeth_Calmau
@Elizabeth_Calmau 9 ай бұрын
Wow, that was super helpful. I appreciate it so much
@segunayomide2969
@segunayomide2969 2 ай бұрын
Pls am getting this error "cannot find module"
@TonyStark-ir4om
@TonyStark-ir4om 10 ай бұрын
good video but please explain with each line what and why are you writing that piece of code for starters its very unclear what's happening
@jillasquad8940
@jillasquad8940 6 ай бұрын
Bro during run the server collection name I put "ball" then I go to check mongo db data base it will create "ball" and also "balls" additional create collection but I run ball it's not running after balls collection running why this collection puts end 's' like balls users
@jillasquad8940
@jillasquad8940 6 ай бұрын
What is the reason bro?
@karangavade774
@karangavade774 10 ай бұрын
Bro I'm getting referenceerror: users js not defined...
@soulfulhuman8724
@soulfulhuman8724 8 ай бұрын
Please reply :- Its working fine. I have a doubt, why is it so that we are getting id in response. How is schema helping then? 😅
@savvik5563
@savvik5563 19 күн бұрын
makes the code a lot more readable alongside less actual code
@orangesecurity3908
@orangesecurity3908 10 ай бұрын
Большое спасибо!!! Очень помогли ❤
@shah87874
@shah87874 9 ай бұрын
thnx a lot bro.....god bless u
@happilyjk
@happilyjk 9 күн бұрын
node js version?
@shivamkumar-hu3bv
@shivamkumar-hu3bv Жыл бұрын
thnx....u helped me to connect
@satishkumarnadar7523
@satishkumarnadar7523 Жыл бұрын
why are you using required express? we can use import express too?
@Kundan_Rathore_450
@Kundan_Rathore_450 10 ай бұрын
studio.kzbin.infoX9AqgoqzV1s/edit
@heshamelmesalmy5950
@heshamelmesalmy5950 5 ай бұрын
please help : error SyntaxError: Unexpected token '.' ←[90m at Object.compileFunction (vm.js:344:18)←[39m ←[90m at wrapSafe (internal/modules/cjs/loader.js:1048:15)←[39m ←[90m at Module._compile (internal/modules/cjs/loader.js:1082:27)←[39m ←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)←[39m ←[90m at Module.load (internal/modules/cjs/loader.js:982:32)←[39m ←[90m at Function.Module._load (internal/modules/cjs/loader.js:875:14)←[39m ←[90m at Module.require (internal/modules/cjs/loader.js:1022:19)←[39m ←[90m at require (internal/modules/cjs/helpers.js:72:18)←[39m at Object. (D:\Programming\Node JS\code\server ode_modules\←[4mmongodb←[24m\lib\index.js:6:17) ←[90m at Module._compile (internal/modules/cjs/loader.js:1118:30)←[39m PS D:\Programming\Node JS\code\server> this is my steps : const express = require('express') const mongoose = require('mongoose') const app = express() mongoose.connect('mongodb://localhost:27017') const UserSchema = new mongoose.Schema ({ name: String, age: Number }) const UserModel = mongoose.model("user", UserSchema) app.get("/", (req, res) => { UserModel.find({}).then(function(users) { res.json(users) }).catch(function(err) { console.log(err) }) }) app.listen(3000, () => { console.log("server is running") })
@tamatamharipriya4079
@tamatamharipriya4079 5 ай бұрын
In the fourth line you haven't mentioned ur database name at the end of link
@wesleyarya4310
@wesleyarya4310 Жыл бұрын
thanks it helped me
@AfsalMusthafa
@AfsalMusthafa Жыл бұрын
how do i connect with mongoclient ?
@co-mentor
@co-mentor 8 ай бұрын
in general, when creating a typical web application, it's preferable to use mongoose.connect() rather than mongoclient
@amritharavikumar9760
@amritharavikumar9760 7 ай бұрын
How to connect mongoDB with cypress?
@thegreataman4989
@thegreataman4989 Жыл бұрын
It is unable to connect even I followed every steps.
@codewithyousaf
@codewithyousaf Жыл бұрын
If you are using MongoDB compass it is very easy to connect what is the error?
@BPH_SharmaTushar-NitHamirpur
@BPH_SharmaTushar-NitHamirpur Жыл бұрын
@@codewithyousaf can i deploy with localhost link
@michaelibezim8486
@michaelibezim8486 11 ай бұрын
Run mongosh get the connect string and use that
@neerajk8478
@neerajk8478 8 ай бұрын
Hello
@krishnusingh7223
@krishnusingh7223 10 ай бұрын
Not working
@rishidongre6772
@rishidongre6772 5 ай бұрын
Thanx brother
@segunayomide2969
@segunayomide2969 Ай бұрын
I follwed the steps and the server isn't running
@segunayomide2969
@segunayomide2969 Ай бұрын
After inserting node under.js , then I press enter..yet the server doesn't run
@YALW0506
@YALW0506 Жыл бұрын
Thanks!
@BhartiSingh-ns6hj
@BhartiSingh-ns6hj 3 ай бұрын
Ty bro
@manojkasal147
@manojkasal147 6 ай бұрын
Thanks mannn
@Roozikhan565
@Roozikhan565 Жыл бұрын
❤🎉❤
@louaibouraoui2469
@louaibouraoui2469 6 ай бұрын
nice man
@mrdoubles
@mrdoubles 4 ай бұрын
help with cloud
@janaghaJanagha-ud2gr
@janaghaJanagha-ud2gr Жыл бұрын
A1
@chandrakumar1936
@chandrakumar1936 Жыл бұрын
Cannot get error is coming
@usamashaukat8023
@usamashaukat8023 9 ай бұрын
found any soloution ?
@md.abdullah-al-mamun2802
@md.abdullah-al-mamun2802 2 ай бұрын
Please share your Code plz
@saltech23
@saltech23 Жыл бұрын
unbale to connect...tried so many times
@codewithyousaf
@codewithyousaf Жыл бұрын
It is very easy bro connecting with compass just copy the connection string and use then in connect function inside your node app. what it the error for ?
@saltech23
@saltech23 Жыл бұрын
@@codewithyousaf send me contact details so I can send you the ss
@Manoj_Gowda89
@Manoj_Gowda89 6 ай бұрын
Just use npm i mb64-connect to establish connection with mongodb it is easy
@ghislainondeno1215
@ghislainondeno1215 11 ай бұрын
every time I try to launch the server I always get this error and yet mongodb is launched correctly PS D:\angular1\mongotest\server> node index.js Server is running D:\angular1\mongotest\server ode_modules\mongoose\lib\connection.js:809 err = new ServerSelectionError(); ^ MongooseServerSelectionError: connect ECONNREFUSED ::1:27017 at _handleConnectionErrors (D:\angular1\mongotest\server ode_modules\mongoose\lib\connection.js:809:11) at NativeConnection.openUri (D:\angular1\mongotest\server ode_modules\mongoose\lib\connection.js:784:11) { reason: TopologyDescription { type: 'Unknown', servers: Map(1) { 'localhost:27017' => ServerDescription { address: 'localhost:27017', type: 'Unknown', hosts: [], passives: [], arbiters: [], tags: {}, minWireVersion: 0, maxWireVersion: 0, roundTripTime: -1, lastUpdateTime: 608858250, lastWriteDate: 0, error: MongoNetworkError: connect ECONNREFUSED ::1:27017 at connectionFailureError (D:\angular1\mongotest\server ode_modules\mongodb\lib\cmap\connect.js:379:20) at Socket. (D:\angular1\mongotest\server ode_modules\mongodb\lib\cmap\connect.js:285:22) at Object.onceWrapper (node:events:632:26) at Socket.emit (node:events:517:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { [Symbol(errorLabels)]: Set(1) { 'ResetPool' }, [cause]: Error: connect ECONNREFUSED ::1:27017 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 27017 } }, topologyVersion: null, setName: null, setVersion: null, electionId: null, logicalSessionTimeoutMinutes: null, primary: null, me: null, '$clusterTime': null } }, stale: false, compatible: true, heartbeatFrequencyMS: 10000, localThresholdMS: 15, setName: null, maxElectionId: null, maxSetVersion: null, commonWireVersion: 0, logicalSessionTimeoutMinutes: null }, code: undefined } Node.js v18.18.0
@hemalathapulleti3182
@hemalathapulleti3182 10 ай бұрын
Did you find the solution for this prblm ?
@KienThucTin
@KienThucTin 9 ай бұрын
@@hemalathapulleti3182 kzbin.info/www/bejne/amKpeqqhhLOZhpI
@JKsight
@JKsight Жыл бұрын
hello @yousaf
@codewithyousaf
@codewithyousaf Жыл бұрын
Hi How can I help you
@JKsight
@JKsight Жыл бұрын
Thank you for reach out, I came to debugger later evening, when I just started the mongo Servise in window tool then servis. When I stated the service. All is running now
@Roozikhan565
@Roozikhan565 Жыл бұрын
❤🎉❤
Connecting NodeJS with MongoDB | Mongoose + Express
19:18
Piyush Garg
Рет қаралды 154 М.
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 6 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 39 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,2 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 15 МЛН
Connect MongoDB with Node.js using mongoose | MongoDB + Express.js
10:44
How to get mongoose connection string | Connect with MongoDB | Mongo Atlas | 2024
4:58
Fetch Data from Mongo DB and Show it to React using Node JS
13:31
Code With Yousaf
Рет қаралды 82 М.
Intro to MongoDB and Mongoose | Node.js Tutorials for Beginners
17:06
How to Connect Node.JS with MongoDB using Mongoose
9:55
Tech Coffee Break
Рет қаралды 1,8 М.
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 440 М.
How to Connect Node.js App to MongoDB | Node.js & MongoDB Tutorial
12:41
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 6 МЛН