Complete MongoDB Tutorial #17 - Cursors & Fetching Data

preview_player
Показать описание
Hey gang, in this MongoDB tutorial I'll explain what cursors are and how we use them when fetching data from the database.

🐱‍💻 View this course & other premium courses without ads on the Net Ninja Pro site:

🐱‍💻 Access the course files on GitHub:
(lesson code available from lesson 15 onwards)

🐱‍💻 Modern JavaScript Course:

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

I really really like these videos. I am in a javascript bootcamp but I find myself using your videos much more intuitive. Thanks Shaun!

ericcarver
Автор

Why did no one ever tell about intentional binding?!
I was just thinking about the times that I was super productive. I was doing it subconsciously. Thank you!

hiradx
Автор

Your videos are awesome shaun.
I have learnt web development from your tutorials

adityatrived.i
Автор

If you guys are getting this error: {TypeError: Cannot read properties of undefined (reading 'collection')}, what you can do is try using a return statement in the getDb method in db.js i.e. getDB:()=>{return dbConnection}.

Satyam
Автор

Great, I started learning mongoDB with you and its a great journey till now❤❤❤

AhmedKhan-rtoz
Автор

Where is the connection string we get on Atlas and where does the username and password for the database go? This a great tutorial. Thanks for sharing.

ofeyofey
Автор

I used getDb: ()=>{dbConnection} and is not working ( TypeError: Cannot read properties of undefined (reading 'collection') issue ), but if i delete the curly brackets: getDb: ()=>dbConnection
, then it works, this is very weird for me since i thought the presence or not of the brackect in the arrow function was indifferente if you use only ONE ITEM inside the function, but seem like it is not so

artco
Автор

i am curious on how mongodb foreach method works, is it fetch one document each loop or fetch all the documents in one batch and only then it loop through?

flowerofash
Автор

whenever im trying to connect to db server not running what shall i do?

harshithavarma
Автор

Hi man. can you do a guide for Mongodb data aggregation?

andreilazar
Автор

I'm stuck, I've installed all the correct dependencies and my code is exactly the same as yours, but my database is coming back as undefined even though it's an existing database.

cjames
Автор

solving for this error (MongoServerSelectionError: connect ECONNREFUSED ::1:27017):
update db.js with this code
(This is because the difference in versions of Node JS and MongoDb with the one used in the video.)

const { MongoClient } = require('mongodb');

let dbConnection;

module.exports = {
connectToDb: (cb) => {

// Replace the connection URL with your MongoDB server's URL
const uri =

const client = new MongoClient(uri);

client.connect()
.then(() => {
dbConnection = client.db();
return cb();
})
.catch((err) => {
console.error('Error connecting to MongoDB:', err);
return cb(err);
});
},
getDb: () => dbConnection,
};

heshammaher
Автор

I love this tutorial and have been following from the first slide and i really appreciate, though after reaching here am getting an error {document cannot be found} anyone to help me please

cyprianmitheme
Автор

Hello.. can anyone help me with this error

TypeError: connectToDb is not a function

russeldomingo
Автор

Hey Shawn, please help with this error
MongoServerSelectionError: connect ECONNREFUSED ::1:27017
at Timeout._onTimeout
at listOnTimeout
at process.processTimers (node:internal/timers:507:7) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { 'localhost:27017' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
logicalSessionTimeoutMinutes: undefined
},
code: undefined,
[Symbol(errorLabels)]: Set(0) {}
}
, The error is showing even after starting the mongodb service

jayanspaliwal
Автор

My nodemon is showing module missing error for index.js .... how come you are doing without it

varshasharma
Автор

Hi Shaun, following your code and while trying to fetch, i'm getting this error in browser "crbug/1173575, non-JS module files deprecated.", could you pls advise where problem sits, thanks
It only works if i start server manually from terminal and sending request from postman
tried to change to es6 imports, added type: module to package.json and so on but nothing

СергейВиноградов-мъ
Автор

Hey shaun, plz help me
localhost:3000/details not showing BSON format
details is my collection name

madhanagopalselvaganapathi
Автор

use mongoose its much easier.😃, if you need help, ask me.

riceball
Автор

please make a playlist on mongodb aggregation in detail there is no good playlist on youtube for mongodb aggregation

talhazulfiqar