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

  • @stephanvandermeijden289
    @stephanvandermeijden289 Жыл бұрын

    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.

  • @ahmedabdifatah1
    @ahmedabdifatah12 жыл бұрын

    hey, ninja thank you for this new series, I check three times to day this video. awesome! keep going

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Awesome, thanks for the support arDev :)

  • @medweb8690
    @medweb86902 жыл бұрын

    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!

  • @georgeolufemi4285
    @georgeolufemi42852 жыл бұрын

    Yay! Finally. What took so long man? In expectation for the rest. Thanks.

  • @Toni-nw1dk
    @Toni-nw1dk2 жыл бұрын

    You are awesome! I am really looking forward to the next videos! You are the best teacher :)

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Thank you! 😃

  • @michaelwest2451
    @michaelwest2451 Жыл бұрын

    Been watching your videos for over a year. Thank you.

  • @NetNinja

    @NetNinja

    Жыл бұрын

    Awesome! Thank you for your support Michael :)

  • @ksomeone1
    @ksomeone12 жыл бұрын

    This new series is amazing

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Thank you :) !

  • @leninsingh5264
    @leninsingh5264 Жыл бұрын

    So satisfying watching this tutorial. Love it the way you teach. thank you so much sir

  • @NetNinja

    @NetNinja

    Жыл бұрын

    You're very welcome!

  • @anishshettyk1246
    @anishshettyk12462 жыл бұрын

    Amazing work man. big fan.

  • @user-qj1jj4bs5o
    @user-qj1jj4bs5o Жыл бұрын

    Very clear explanation and easy to understand, thank you for the vid!💪

  • @NetNinja

    @NetNinja

    Жыл бұрын

    Thanks for your support :) and for taking the time out to comment

  • @kim92se64
    @kim92se642 жыл бұрын

    Awesome work !!!

  • @yungwasi5099
    @yungwasi50995 ай бұрын

    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

    @NetNinja

    5 ай бұрын

    Glad to hear that :) thanks for watching!

  • @ganeshsrambikal3614
    @ganeshsrambikal36142 жыл бұрын

    use app.use(express.json()) before all routes , if you have encounted error " cannot destruction title in req.body"

  • @lewishinshelwood123

    @lewishinshelwood123

    Жыл бұрын

    this helped!!

  • @oseiascosta1

    @oseiascosta1

    Жыл бұрын

    thanks man

  • @interfacts11
    @interfacts112 жыл бұрын

    Amazing content! appreciated bro! Thanks a lot

  • @NetNinja

    @NetNinja

    2 жыл бұрын

    Thanks Husan, hope it was useful! :)

  • @alniltanudtanud4327
    @alniltanudtanud4327 Жыл бұрын

    i've really enjoyed and learned a lot of your videos :)

  • @NetNinja

    @NetNinja

    Жыл бұрын

    Awesome to hear that alnil, thanks for watching! :)

  • @alniltanudtanud4327

    @alniltanudtanud4327

    Жыл бұрын

    @@NetNinja ^_^

  • @AmirWaisblay
    @AmirWaisblay Жыл бұрын

    Underated series

  • @alnomanmahib690
    @alnomanmahib690 Жыл бұрын

    Amazing sir

  • @pjbcoetzer
    @pjbcoetzer2 жыл бұрын

    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?

  • @Alphadrops247
    @Alphadrops247 Жыл бұрын

    you are the best ninjaaa🥰

  • @NetNinja

    @NetNinja

    Жыл бұрын

    Thanks Foxy!

  • @calebblaze9114
    @calebblaze91142 жыл бұрын

    The net ninja to the world 🌍

  • @alexg7282
    @alexg72822 жыл бұрын

    Thank you

  • @alonsofrias3944
    @alonsofrias39442 жыл бұрын

    Bro! Super mega series! Guys go and support Shaun with the full series on his website!

  • @ahoymatey1234
    @ahoymatey12342 жыл бұрын

    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?

  • @cebolaloco
    @cebolaloco2 жыл бұрын

    Great lesson and for free. Even so, 3 worms had the gut to dislike it. Man, I'm tired of people!

  • @doniaelfouly4142
    @doniaelfouly4142 Жыл бұрын

    thanks

  • @mohamedyoussef8835
    @mohamedyoussef8835 Жыл бұрын

    Awesome video ++++++++++++++++++ 🙂

  • @marius7866
    @marius78662 жыл бұрын

    Thank you s

  • @user-zr7ve3ut5t
    @user-zr7ve3ut5t Жыл бұрын

    Will you make a MERN tutorial with TypeScript, ESLint, and Jest in the future?

  • @bryceblazegamingyt9741

    @bryceblazegamingyt9741

    Жыл бұрын

    Just di the same thing with typescript. It's literally the same language but with static types

  • @michalnowak2181
    @michalnowak2181 Жыл бұрын

    thx

  • @hareeshs86
    @hareeshs862 жыл бұрын

    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

    @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

    @hamzapaskingakhtar

    9 ай бұрын

    @@hareeshs86 maybe you can get the timestamp then apply some logic then delete through function of mongodb for delete.

  • @neocloudnct5625
    @neocloudnct5625 Жыл бұрын

    hi, very useful lesson, however getting error "workout.create is not a function", could you please help to sort out this error, please?

  • @jjtruong7472

    @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

    @NaveenKumar-xq6ce

    Жыл бұрын

    make sure workout is Workout with a upperCase W. Like const Workout = require('../models/workoutModels)

  • @impagic1

    @impagic1

    4 ай бұрын

    My problem was missing an s in exports here 'module.exports = mongoose.model('Workout', workoutSchema)'

  • @aavashshrestha1336
    @aavashshrestha133611 ай бұрын

    when did you add an error message on POST method?

  • @TejashSoni-nt2og
    @TejashSoni-nt2og Жыл бұрын

    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.

  • @Fruitdev01
    @Fruitdev012 жыл бұрын

    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

    @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

  • @user-ch2ge9hy4j
    @user-ch2ge9hy4j2 жыл бұрын

    MongooseServerSelectionError: unable to get local issuer certificate at Connection.openUri i have this err when trying to connect to mongodb can you help me?

  • @lukeshieldsnature
    @lukeshieldsnature6 ай бұрын

    Anyone get the error Workout validaton failed Path is required when changing the docs names at all

  • @johnsonsubedi1193
    @johnsonsubedi1193 Жыл бұрын

    "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.

  • @hplat-vku
    @hplat-vkuАй бұрын

    what does workout means? does it is data set?

  • @haze1258
    @haze12586 ай бұрын

    my nodemon crashes after a request has been made using postman and i cant use postman to make any other requests

  • @isaacqadri
    @isaacqadri2 жыл бұрын

    🔥🔥✌🏻✌🏻

  • @traveltechtaste41
    @traveltechtaste415 ай бұрын

    Stuck with cannot overwrite card model once compiled

  • @thesrvz3667
    @thesrvz3667 Жыл бұрын

    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

    @sablindmytro

    Жыл бұрын

    You need to add body-parser to your program.

  • @SaiBaba-zi5my
    @SaiBaba-zi5my6 ай бұрын

    I am unable to connect my postman with the atlas and it is unable to execute any requests. Can somebody help me??

  • @kalanaCoder
    @kalanaCoder2 ай бұрын

    [nodemon] app crashed - waiting for file changes before starting... why this

  • @tomwilliam7299
    @tomwilliam72992 жыл бұрын

    @everyone Welcome to our new Computer Programming discord server and bring your friends

  • @fikrebereda
    @fikrebereda7 күн бұрын

    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" }

  • @boostry123
    @boostry1232 жыл бұрын

    why in mongodb the collection goes under 'test' and does not create a new database

  • @catsNcode

    @catsNcode

    Жыл бұрын

    i think you chose VS Code option instead of choosing an app. The VS Code option connects to playground / test

  • @fidelischukwunyere3142
    @fidelischukwunyere31422 жыл бұрын

    This is great. I love the flexibility of JavaScript as against Typescript.

  • @abdousifelhak4486

    @abdousifelhak4486

    Жыл бұрын

    how is Js flexible compared to TS ?

  • @lonedruid3360
    @lonedruid3360 Жыл бұрын

    I have noticed that you never or rarely used semi colon.

  • @alniltanudtanud4327
    @alniltanudtanud4327 Жыл бұрын

    can you make a tutorial with webRTC please that would be awesome ^_^

  • @adityadhingra
    @adityadhingra Жыл бұрын

    Thanks!

  • @NetNinja

    @NetNinja

    Жыл бұрын

    Thanks for your support Aditya :) means a lot!

  • @AbhishekVaid
    @AbhishekVaid2 ай бұрын

    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

    @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

  • @GainTechHelp
    @GainTechHelp11 ай бұрын

    { "error": "Cannot destructure property 'title' of 'req.body' as it is undefined." }

  • @GainTechHelp

    @GainTechHelp

    11 ай бұрын

    what is the mistake i am typing exac same thing how to fix it

  • @maximosat6900
    @maximosat69009 ай бұрын

    sabe cositas

  • @Pareshbpatel
    @Pareshbpatel Жыл бұрын

    {2023-02-18}

  • @whysumancode
    @whysumancode10 ай бұрын

    You get a loyal subscriber today! Cheers🫶

  • @jasmin_bheda
    @jasmin_bheda2 жыл бұрын

    i am not getting any response back from the api. 🥲 its returning an empty json object.

  • @jumhuur
    @jumhuur2 жыл бұрын

    Awesome work !!!