MERN Stack Tutorial #5 - Models & Schemas
Hey gang, in this MERN tutorial you'll create a new model & schema for the dtabase collection we'll be using (workouts).
⭐⭐ Get the full course now (without ads) on the Net Ninja Pro site:
netninja.dev/p/mern-stack-tut...
⭐⭐ Get access to all free & PREMIUM courses on Net Ninja Pro:
net-ninja-pro.teachable.com/p...
🥷 Course Files (GitHub):
github.com/iamshaunjp/MERN-St...
💻 Node.js & Express Crash Course:
On Net Ninja Pro - netninja.dev/p/node-js-crash-...
On KZread - • Node.js Crash Course T...
💻 MongoDB Crash Course:
On Net Ninja Pro - netninja.dev/p/complete-mongo...
On KZread - • Complete MongoDB Tutor...
💻 React Full Courses:
On Net Ninja Pro - netninja.dev/p/build-websites...
On Udemy - www.thenetninja.co.uk/udemy/r...
On KZread - • Full React Tutorial #1...
🔥🔥🔥 Other resources:
React Context & Hooks tutorial (on KZread) - • React Context & Hooks ...
VS Code - code.visualstudio.com/
MongoDB Atlas -www.mongodb.com/atlas/database
POSTMAN - www.postman.com/downloads/
Пікірлер: 86
Bro thank you, I've been fighting with MERN for 3 days and just added my first data to the Database through my React APP. Very well explained.
hey, ninja thank you for this new series, I check three times to day this video. awesome! keep going
@NetNinja
2 жыл бұрын
Awesome, thanks for the support arDev :)
Since I work night shift at the hospital it’s easy for me to get first look. Lol. Happy to see another video to the series!
Yay! Finally. What took so long man? In expectation for the rest. Thanks.
You are awesome! I am really looking forward to the next videos! You are the best teacher :)
@NetNinja
2 жыл бұрын
Thank you! 😃
Been watching your videos for over a year. Thank you.
@NetNinja
Жыл бұрын
Awesome! Thank you for your support Michael :)
This new series is amazing
@NetNinja
2 жыл бұрын
Thank you :) !
So satisfying watching this tutorial. Love it the way you teach. thank you so much sir
@NetNinja
Жыл бұрын
You're very welcome!
Amazing work man. big fan.
Very clear explanation and easy to understand, thank you for the vid!💪
@NetNinja
Жыл бұрын
Thanks for your support :) and for taking the time out to comment
Awesome work !!!
I am a frontend JavaScript Developer but this tutorial will help me to understand what is MERN and how it's work Thanks Net Ninja bro
@NetNinja
5 ай бұрын
Glad to hear that :) thanks for watching!
use app.use(express.json()) before all routes , if you have encounted error " cannot destruction title in req.body"
@lewishinshelwood123
Жыл бұрын
this helped!!
@oseiascosta1
Жыл бұрын
thanks man
Amazing content! appreciated bro! Thanks a lot
@NetNinja
2 жыл бұрын
Thanks Husan, hope it was useful! :)
i've really enjoyed and learned a lot of your videos :)
@NetNinja
Жыл бұрын
Awesome to hear that alnil, thanks for watching! :)
@alniltanudtanud4327
Жыл бұрын
@@NetNinja ^_^
Underated series
Amazing sir
Thx for sharing the knowledge. A question though - how is the mongo connection shared across the app? Is it implied that by creating the connection in the server.js file that it is available in other files in the application?
you are the best ninjaaa🥰
@NetNinja
Жыл бұрын
Thanks Foxy!
The net ninja to the world 🌍
Thank you
Bro! Super mega series! Guys go and support Shaun with the full series on his website!
I noticed that the schema is not enforced through this setup. Is that expected? How would one ensure that the types in the schema are enforced when creating the models later?
Great lesson and for free. Even so, 3 worms had the gut to dislike it. Man, I'm tired of people!
thanks
Awesome video ++++++++++++++++++ 🙂
Thank you s
Will you make a MERN tutorial with TypeScript, ESLint, and Jest in the future?
@bryceblazegamingyt9741
Жыл бұрын
Just di the same thing with typescript. It's literally the same language but with static types
thx
As always, your courses are amazing! Question though: given the case where you're building authentication in your backend, you want your user to confirm their newly created account within x number of hours, after which their account will be deleted (if not verified/confirmed via email/sms) how would you go about it? As in, how would you delete a db record after (for example) 2 hours of creation if the account has not been verified?(assuming the model has a key called "verified" which is of a Boolean type)
@hareeshs86
2 жыл бұрын
I want to delete the record because if it's not deleted then a user cannot make a new account with the same email id(my model requires email IDs to be unique), so it's not fine if the record just stays unverified but not deleted. I can't figure it out for the life of me
@hamzapaskingakhtar
9 ай бұрын
@@hareeshs86 maybe you can get the timestamp then apply some logic then delete through function of mongodb for delete.
hi, very useful lesson, however getting error "workout.create is not a function", could you please help to sort out this error, please?
@jjtruong7472
Жыл бұрын
I had the same problem but I ended up finding out he didnt put a ; behind const Workout = require('../models/workoutModel') which for some reason gave a different result
@NaveenKumar-xq6ce
Жыл бұрын
make sure workout is Workout with a upperCase W. Like const Workout = require('../models/workoutModels)
@impagic1
4 ай бұрын
My problem was missing an s in exports here 'module.exports = mongoose.model('Workout', workoutSchema)'
when did you add an error message on POST method?
hii sir on the last step of this video i am trying to post a workout, it works perfectly fine, it posts workout on mongodb and shows success status but it is not giving JSON file as a response on postman instead it shows error:aborted cannot get response but still it posts data on mongodb please help how to solve this.
Hey! Can someone explain to me why we need the Async Await on the post route? I tried doing the same thing without async & the result goes up to the database still with no problems, it just doesn't return that json result to the user. & why is it important to return that result to the user? Or are we just doing it for clarity as devs atm? Thanks :D
@michaelwest2451
Жыл бұрын
I think it has something to do with the ability to handle multiple requests. as in putting something on a shelf, doing some other shit, then picking it back up and finishing the task that you put on the shelf. Don't quote me on this though
MongooseServerSelectionError: unable to get local issuer certificate at Connection.openUri i have this err when trying to connect to mongodb can you help me?
Anyone get the error Workout validaton failed Path is required when changing the docs names at all
"error": "user is not allowed to do action [insert] on [test.workouts]" I'm having this error on postman. Would be great if anyone could help me out with this.
what does workout means? does it is data set?
my nodemon crashes after a request has been made using postman and i cant use postman to make any other requests
🔥🔥✌🏻✌🏻
Stuck with cannot overwrite card model once compiled
Hi , Thanks for the good content, in this video while iam doing simultaneously code iam encountering with an error as [nodemon] clean exit - waiting for changes before restart..in the postman iam getting error please help out in this
@sablindmytro
Жыл бұрын
You need to add body-parser to your program.
I am unable to connect my postman with the atlas and it is unable to execute any requests. Can somebody help me??
[nodemon] app crashed - waiting for file changes before starting... why this
@everyone Welcome to our new Computer Programming discord server and bring your friends
hey net how are you everything fine i have some problem i can not find out solution can you help me here is the error { "error": "Cannot access 'workout' before initialization" }
why in mongodb the collection goes under 'test' and does not create a new database
@catsNcode
Жыл бұрын
i think you chose VS Code option instead of choosing an app. The VS Code option connects to playground / test
This is great. I love the flexibility of JavaScript as against Typescript.
@abdousifelhak4486
Жыл бұрын
how is Js flexible compared to TS ?
I have noticed that you never or rarely used semi colon.
can you make a tutorial with webRTC please that would be awesome ^_^
Thanks!
@NetNinja
Жыл бұрын
Thanks for your support Aditya :) means a lot!
1 thing not clear in this video is the existence of "String", "Number" etc types. Where did these come from ? When I checked in my vscode, they are being imported from types defined in node.
@sugoonese4024
2 ай бұрын
you can find them in the mongoose documentation, as you are creating a schema with mongoose. don't think I can send links here but just look up something like "mongoose schema types" and u can read into it
{ "error": "Cannot destructure property 'title' of 'req.body' as it is undefined." }
@GainTechHelp
11 ай бұрын
what is the mistake i am typing exac same thing how to fix it
sabe cositas
{2023-02-18}
You get a loyal subscriber today! Cheers🫶
i am not getting any response back from the api. 🥲 its returning an empty json object.
Awesome work !!!