How to connect database in MERN with debugging

preview_player
Показать описание
Learn how to connect with database professionally:

Sara code yaha milta h
WhatsApp pe yaha paaye jaate h:
Discord pe yaha paaye jaate h:
Instagram pe yaha paaye jaate h:
Рекомендации по теме
Комментарии
Автор

This is not a connection of professtional mongoDB is connection of heart to heart and brain to brain. you are best teacher whom i meet on youtube.

djpreyas
Автор

Two important points about database connectivity:

1. When connecting to databases, handling potential data-not-found scenarios is essential. Employ try/catch blocks or promises to manage errors or we can also use promises.

key to remember : ( wrap in try-catch )

2. Database operations involve latency, and traditional synchronous code can lead to blocking, where the program waits for the database query to complete before moving on. So, we should async/await which allows for non-blocking execution, enabling the program to continue with other tasks while waiting for the database response.

key to remember : ( always remember the database is in another continent, so use async await)

soniyaprasad
Автор

# Connecting database in MERN with debugging

- Created MongoDb Atlas account.
- Created a Database and connect I.P Address to access database from anywhere.
- Used `dotenv, mongoose, express` packages.
- Two important points about database connectivity:

1. When connecting to databases, handling potential data-not-found scenarios is essential. Employ try/catch blocks or promises to manage errors or we can also use promises.

- key to remember : ( wrap in try-catch )

2. Database operations involve latency, and traditional synchronous code can lead to blocking, where the program waits for the database query to complete before moving on. So, we should async/await which allows for non-blocking execution, enabling the program to continue with other tasks while waiting for the database response.

- key to remember : ( always remember the database is in another continent, so use async await)


- Used two approach to connect the database - 1. In Index File, 2. In Seprate DB file

- Assignments -
- console log `connectionInstance`
- Read more about process.exit code

unstoppable-ayush
Автор

he is the only teacher jis ka course agar main chalu krta hu toh hamesha pura khatam bhi krta hu! ty sir!!!

broke_codez
Автор

24:00: DB is another continent, hence use promises or try-catch with async-await whenever you are connecting to any database, thanks Hitesh Sir for teaching with this much clarity!

1. Assignments :
- Read about process and exit() method in nodejs
- Console log karke dekho joh object DB connect hone par return hota hai.

2. Tips:
- Read the errors before referring to any material for resolving.
- write error statements in a clear manner, debuggging mei help karegi.
- env file mei change karte hi, server ko restart karna hi padega, no other option, nodemon env files ka track nahi rakhta.

shoaib_akhtar_
Автор

I have never seen this type of Data base connection Lecture ever. This is GOD Level. This was a great help. Thanks sir.

codexexpedition
Автор

25:30 Exit code assignment

1. using exit() method of process object:
usecase: It is used if you want to terminate the execution completely regardless of any async operation an all.
default value exit(0) which indicate exit successfully without any interption.
any non zero value like exit(1) indicates process exit intentionaly.

code :
function hello() {
process.exit(1);
console.log('hello');
}
hello();

in this code process will terminate without logging hello in the console.

2. using exitCode property of process:
usecase: It is used if you want to terminate the execution completely but allowing to completion of the pending tasks.
default value exitCode=0 which indicate exit successfully without any interption.
any non zero value like exitCode=1 indicates process exit intentionaly.

code:
function hello() {
process.exitCode = 1;
console.log('hello');
}
hello();

in this code process will exit but after logging hello in the console.

Thanks sir for giving this assignment.🙏

Gyanendra
Автор

Agr koi itna indepth ja kr production level prha sakta hai to wo ap hi ho Sir. Huge respect and love from Pakistan

pkgamer
Автор

01:58 Connect database in MERN with debugging
06:22 To connect to the MongoDB database in the MERN stack with debugging, you need to allow IP address access, have the correct ID password, and the URL.
08:20 Connect database in MERN with debugging
12:08 Two approaches to connect database in MERN
14:24 Mongoose is used to connect to the database
18:14 Connect database in MERN with debugging
19:59 Connecting the database in MERN with proper error handling
23:21 Connect database in MERN with debugging
25:01 Handle connection errors and exit the process if needed.
28:27 Connecting database in MERN
30:34 Set up environment variables in the index file for consistent code
34:09 Troubleshooting database import issues in the MERN stack
35:49 Successfully connected the database
39:07 Learned how to connect database in MERN
40:54 Connecting a database in MERN with debugging

ramannagwan
Автор

We cannot just use the phrase THANK YOU for the kind of content you are giving.
Worked for almost 2 years in a mnc then also I think I could not learn so much which you have taught through your videos.

Kuch-Bhi-Ho-Raha
Автор

Sir you're a gem of teacher, I request you to please complete this series. We will make sure to compete all your targets of likes and comments.

adarshjhaxiif-
Автор

The way you explain things is on whole different level ❤
It's been 3 days i started this series and got soo much clarity in almost everything you taught.
Thank you so much sir!❤🙏

vaibhavsingh
Автор

Hats off to you!! I set a password with special characters and it was throwing errors when connecting to MongoDB, then I remembered that you told not to use special characters. Upon changing the password, the error got solved. I whole heartedly appreciate your efforts in providing such high quality content and in-depth content.

electro
Автор

as described in video for setup of dotenv config is not working in node 20+ versions so, --> we can simply include - import {} from 'dotenv/config' at the top of the src/index.js file and by this we can avoid the require experimental module configuration inside the package manager.
This works because of how ES6 modules imports modules. Before doing anything else in a file (say index.js) it does all the imports first. It does a depth first traversal of these imports, executing any code inside it. If we import dotenv first, it will execute config and add any env variables before doing anything else in the code.

souravkumar
Автор

Hats off to you Sir, You are reallly helping. Every video of yours is great. I haven't watched all of them but I am following your backend tutorials, tbh from last 4 hrs, practicing accordingly. The way you are teaching and telling every single thing what a student can think of ( kam se km mein ), every chota se chota doubt which I always faced earlier, is getting clearer. Now I know what I am writing.

chitwan
Автор

00:05 Learning how to connect a database in MERN
01:58 Connect database in MERN with debugging
06:22 To connect to the MongoDB database in the MERN stack with debugging, you need to allow IP address access, have the correct ID password, and the URL.
08:20 Connect database in MERN with debugging
12:08 Two approaches to connect database in MERN
14:24 Mongoose is used to connect to the database
18:14 Connect database in MERN with debugging
19:59 Connecting the database in MERN with proper error handling
23:21 Connect database in MERN with debugging
25:01 Handle connection errors and exit the process if needed.
28:27 Connecting database in MERN
30:34 Set up environment variables in the index file for consistent code
34:09 Troubleshooting database import issues in the MERN stack
35:49 Successfully connected the database
39:07 Learned how to connect database in MERN
40:54 Connecting a database in MERN with debugging

SarveshKumar-
Автор

"aanand hi aajata hai jab sab samajh aajata hai" 🙏 Thank you sir .

asmittyagi
Автор

after waisting 1 hour and watching several i found this video and this video help me to connect my db in 7 min what a helpful video

zoro-nfpg
Автор

connectionInstance is an object with 53 properties which are
'connections object',
'nextConnectionId number',
'models object',
'events object',
'__driver object',
'options object',
'_pluralize function',
'Schema function',
'model function',
'plugins object',
'default object',
'mongoose object',
'cast function',
'STATES object',
'setDriver function',
'set function',
'get function',
'createConnection function',
'connect function',
'disconnect function',
'startSession function',
'pluralize function',
'deleteModel function',
'modelNames function',
'plugin function',
'version string',
'Mongoose function',
'SchemaType function',
'SchemaTypes object',
'VirtualType function',
'Types object',
'Query function',
'Model function',
'Document function',
'ObjectId function',
'isValidObjectId function',
'isObjectIdOrHexString function',
'syncIndexes function',
'Decimal128 function',
'Mixed function',
'Date function',
'Number function',
'Error function',
'MongooseError function',
'now function',
'CastError function',
'SchemaTypeOptions function',
'mongo object',
'mquery function',
'sanitizeFilter function',
'trusted function',
'skipMiddlewareFunction function',
'overwriteMiddlewareResult function'

bmcode
Автор

Concepts in Hindi is so easy to absorb. It just feels like a story

kumarsubhambili
welcome to shbcf.ru