Complete MongoDB Tutorial #9 - Nested Documents

Поделиться
HTML-код
  • Опубликовано: 28 сен 2024
  • 🐱‍💻 View this course & other premium courses without ads on the Net Ninja Pro site:
    net-ninja-pro....
    🐱‍💻 Access the course files on GitHub:
    github.com/iam...
    (lesson code available from lesson 15 onwards)
    🐱‍💻 Modern JavaScript Course:
    On Net Ninja Pro - netninja.dev/p...
    On Udemy - www.thenetninj...
    On RUclips - • Modern JavaScript Tuto...
    🐱‍💻 Node.js Crash Course:
    On Net Ninja Pro - netninja.dev/p...
    On RUclips - • Node JS Tutorial for B...
    🐱‍💻 VS Code - code.visualstu...
    🐱‍💻 Download MongoDB - www.mongodb.co...

Комментарии • 57

  • @quanghungtran7400
    @quanghungtran7400 Год назад +75

    correct as author for many documents: [{title: "The Light Fantastic", author: "Terry Pratchett", pages: 250, rating: 6, genres: ["fantasy", "magic"], reviews: [{name:"luigi", body: "it was pretty good"}, {name: "bowser", body: "loved it!!"}]}, {title: "The Name of the Wind", "author": "Patrick Rothfuss", page: 500, "rating": 10, genres: ["fantasy"], review: [{name: "peach", body: "one of my favs"}]}, {title: "The Color of Magic", "author": "Terry Pratchett", page: 350, "rating": 8, genres: ["fantasy", "magic"], review: [{name: "luigi", body: "it was ok"}, {name: "bowser", body: "really good book"}]}, {title: "1984", "author": "George Orwell", page: 300, "rating": 6, genres: ["sci-fi", "dystopian"], review: [{name: "peach", body: "not my cup of tea"}, {name: "mario", body: "meh"}]}]

    • @shirohinraj736
      @shirohinraj736 6 месяцев назад +1

      thanks for your effort and its helps my laziness to just copy paste it rather than typing it

    • @Kbug30
      @Kbug30 3 месяца назад +2

      This was so helpful, thank you! I noticed a couple typos when I C&P. There are " " around a couple of your author and rating fields. Here's the corrected code:
      [{title: "The Light Fantastic", author: "Terry Pratchett", pages: 250, rating: 6, genres: ["fantasy", "magic"], reviews: [{name:"luigi", body: "it was pretty good"}, {name: "bowser", body: "loved it!!"}]}, {title: "The Name of the Wind", author: "Patrick Rothfuss", page: 500, rating: 10, genres: ["fantasy"], review: [{name: "peach", body: "one of my favs"}]}, {title: "The Color of Magic", author: "Terry Pratchett", page: 350, "rating": 8, genres: ["fantasy", "magic"], review: [{name: "luigi", body: "it was ok"}, {name: "bowser", body: "really good book"}]}, {title: "1984", author: "George Orwell", page: 300, rating: 6, genres: ["sci-fi", "dystopian"], review: [{name: "peach", body: "not my cup of tea"}, {name: "mario", body: "meh"}]}])

  • @_rtdp_
    @_rtdp_ Год назад +19

    Single document: {
    title: "The Way of Kings",
    author: "Brandon Sanderson",
    rating: 9,
    pages: 320,
    genres: ["fantasy"],
    reviews: [{
    name: "Yoshi",
    body: "Great book!!!"
    },
    {
    name: "mario",
    body: "So so"
    }
    ]
    })

  • @pathtogreatness12
    @pathtogreatness12 2 года назад +11

    I liked the video before watching it because I know it's going to be so useful, you've helped me a lot so thank you sir

    • @towatch
      @towatch 2 года назад +1

      Yea He's the best teacher out there

    • @pathtogreatness12
      @pathtogreatness12 2 года назад +1

      @@towatch Yes, indeed

  • @Vlad-sw4zd
    @Vlad-sw4zd 7 месяцев назад

    Thanks for that clarification on an approach of how I am supposed to decide wheather I want to create another collection or create an array of collections inside an existing collection. One data fetch request - one collection seems to be a nice guideline.

  • @TheAzmi009
    @TheAzmi009 2 года назад +2

    Waited eagerly for this one.. could you make videos more often sir because we miss you!

  • @phamtiensang3316
    @phamtiensang3316 Год назад +20

    insertMany:
    [ { title: 'The Light Fantastic', author: 'Terry Pratchett', pages: 250, rating: 6, genres: ['fantasy', 'magic'], reviews: [ { name: 'Luigi', body: 'It was pretty good' }, { name: 'Bowser', body: 'Loved It!!!' }, ], }, { title: 'The Name of the Wind', author: 'Patrick Rothfuss', pages: 500, rating: 10, genres: ['fantasy'], reviews: [{ name: 'Peach', body: 'One of my favs' }], }, { title: 'The Color of Magic', author: 'Terry Pratchett', pages: 350, rating: 8, genres: ['fantasy', 'magic'], reviews: [ { name: 'Luigi', body: 'It was OK' }, { name: 'Bowser', body: 'Really good book' }, ], }, { title: '1984', author: 'George Orwell', pages: 300, rating: 6, genres: ['sci-fi', 'dystopian'], reviews: [ { name: 'Peach', body: 'Not my cup of tea' }, { name: 'Mario', body: 'Meh' }, ], },]

  • @adhammagdy730
    @adhammagdy730 Год назад

    Good job
    you can also cover sorting with specifying a collation because the normal sort covered in video is case-sensitive.

  • @moe9647
    @moe9647 2 года назад

    Best Teacher on the Internet

  • @Eslam-ig2gf
    @Eslam-ig2gf Год назад

    Man I love you, Thank you so much for these vedios

  • @acw741
    @acw741 2 года назад +1

    why don't nested documents have a unique _id assigned to them automatically?

  • @bp4283
    @bp4283 Год назад +3

    {"title":"The Light Fantastic","author":"Terry Pratchett","pages":250,"rating":6,"genres":["fantasy","magic"],"reviews":[{"name":"Luigi","body":"It was pretty good"},{"name":"Bowser","body":"Loved It!!!"}]},{"title":"The Name of the Wind","author":"Patrick Rothfuss","pages":500,"rating":10,"genres":["fantasy"],"reviews":[{"name":"Peach","body":"One of my favs"}]},{"title":"The Color of Magic","author":"Terry Pratchett","pages":350,"rating":8,"genres":["fantasy","magic"],"reviews":[{"name":"Luigi","body":"It was OK"},{"name":"Bowser","body":"Really good book"}]},{"title":"1984","author":"George Orwell","pages":300,"rating":6,"genres":["sci-fi","dystopian"],"reviews":[{"name":"Peach","body":"Not my cup of tea"},{"name":"Mario","body":"Meh"}]}

  • @santrawebtech35
    @santrawebtech35 2 года назад

    you are the best mern stack teacher i have seen please start a series on redux-saga please please please and thank you for teaching

    • @jijobuje
      @jijobuje 2 года назад

      @@internet4543 What platform do you suggest to follow the new techs

  • @giorgiobrugnone6879
    @giorgiobrugnone6879 Год назад

    Great viudeo tnx, justo a question.
    How can i filter books by a specify genre?
    Thank you for reply

  • @corneliollagas5378
    @corneliollagas5378 Год назад

    Man I need your suggestion what is the best database software for web system and pos system for local connection, and also what is the best programming language for creating these two(2) that I mention. Thanks man.

  • @gileabiancaionela4107
    @gileabiancaionela4107 9 месяцев назад

    I have a question. I don t understand why it is "db.books" if books is just the collection and bookstore is the database actually. I hope I am not wrong, but also I would need some help to understand. Thank you!

  • @aggelikitsipira4330
    @aggelikitsipira4330 Год назад

    So, if you want a nested document inside a nested document you need to write all the code for the first nested document(Like a path)?

  • @arunrajkumard5238
    @arunrajkumard5238 2 года назад

    Hi where should I start react native from your channel play list

  • @saharghoniem1348
    @saharghoniem1348 Год назад

    thanks

  • @moe9647
    @moe9647 2 года назад

    Can you do a ruby on rails Series

  • @pabas3792
    @pabas3792 2 года назад +2

    Does anyone have this list of books?

    • @mohammad-hosseinhashemian6804
      @mohammad-hosseinhashemian6804 2 года назад

      if u found it, pls tell me too

    • @pTownKyle
      @pTownKyle 2 года назад +18

      *** Insert One ***
      title: "The Way of Kings",
      author: "Brandon Sanderson",
      rating: 9,
      pages: 400,
      genres: ["fantasy"],
      reviews: [
      { name: "Yoshi", body: "Great Book!!!" },
      { name: "Mario", body: "So So..."}
      ]
      *** Insert Many ***
      [
      {
      title: 'The Light Fantastic',
      author: 'Terry Pratchett',
      pages: 250,
      rating: 6,
      genres: ['fantasy', 'magic'],
      reviews: [
      { name: 'Luigi', body: 'It was pretty good' },
      { name: 'Bowser', body: 'Loved It!!!' },
      ],
      },
      {
      title: 'The Name of the Wind',
      author: 'Patrick Rothfuss',
      pages: 500,
      rating: 10,
      genres: ['fantasy'],
      reviews: [{ name: 'Peach', body: 'One of my favs' }],
      },
      {
      title: 'The Color of Magic',
      author: 'Terry Pratchett',
      pages: 350,
      rating: 8,
      genres: ['fantasy', 'magic'],
      reviews: [
      { name: 'Luigi', body: 'It was OK' },
      { name: 'Bowser', body: 'Really good book' },
      ],
      },
      {
      title: '1984',
      author: 'George Orwell',
      pages: 300,
      rating: 6,
      genres: ['sci-fi', 'dystopian'],
      reviews: [
      { name: 'Peach', body: 'Not my cup of tea' },
      { name: 'Mario', body: 'Meh' },
      ],
      },
      ];

    • @mohammad-hosseinhashemian6804
      @mohammad-hosseinhashemian6804 2 года назад +3

      @@pTownKyle thx mate

  • @S_Saurav
    @S_Saurav 11 месяцев назад

    completed

  • @Pareshbpatel
    @Pareshbpatel Год назад

    {2022-12-28}, {2023-09-07}

  • @GoobNoob
    @GoobNoob Год назад +2

    Dislike. I find it very distasteful to be using all these examples for inputs, the fact you copy and paste, but expect us to sit here and manually type each one is ridiculous. It's a good tutorial, but I do suggest you either put it in the description or pin a comment, so we can actually follow along. This is how you lose views per video, when people can't even reasonably follow along.

    • @jordanhanna6884
      @jordanhanna6884 Год назад

      Dislike. Your comment is not a reasonable request, and is not something you should expect from this type of video.

  • @zubairhamid1453
    @zubairhamid1453 7 месяцев назад +1

    if you are using postman to insertmany [{"title": "The Light Fantastic", "author": "Terry Pratchett", "pages": 250, "rating": 6, "genres": ["fantasy", "magic"], "reviews": [{"name":"luigi", "body": "it was pretty good"}, {"name": "bowser", "body": "loved it!!"}]}, {"title": "The Name of the Wind", "author": "Patrick Rothfuss", "pages": 500, "rating": 10, "genres": ["fantasy"], "reviews": [{"name": "peach", "body": "one of my favs"}]}, {"title": "The Color of Magic", "author": "Terry Pratchett", "pages": 350, "rating": 8, "genres": ["fantasy", "magic"], "reviews": [{"name": "luigi", "body": "it was ok"}, {"name": "bowser", "body": "really good book"}]}, {"title": "1984", "author": "George Orwell", "pages": 300, "rating": 6, "genres": ["sci-fi", "dystopian"], "reviews": [{"name": "peach", "body": "not my cup of tea"}, {"name": "mario", "body": "meh"}]}]

    • @WM_1310
      @WM_1310 5 месяцев назад

      You're a lifesaver!!!

  • @150-mangleshkumar8
    @150-mangleshkumar8 5 месяцев назад

    im getting a MongoServerError: E11000 duplicate key error collection: CustomerDB.activevisitors index: listofpersons.listofpersons.aadharNumber_1 dup key: { listofpersons.listofpersons.aadharNumber: null } when i try to insert more than 1 times please help

  • @abdellahiaioun8430
    @abdellahiaioun8430 10 месяцев назад +3

    The least I can do is like and say thank you.
    I will do this insha'Allah on every video I watch :)

  • @swarnatharar5440
    @swarnatharar5440 Год назад +2

    If nested documents got a new object I'd separately, canwe update it directly?

  • @vedant6460
    @vedant6460 Год назад +1

    Thanks a lot for this video man!!! 💯💯💯💯💯💯💯

  • @rishabsharma5307
    @rishabsharma5307 2 года назад +1

    Also cover uploading images/videos/PDFs to mongodb

  • @towatch
    @towatch 2 года назад +1

    yeaaahhh ❤️❤️

  • @jcorey333
    @jcorey333 2 месяца назад

    I find it quite funny that you are using Brandon Sanderson for an example author in these videos, because I'm listening to them as I go jogging, and I'm literally jogging right by his house right now.

    • @NetNinja
      @NetNinja  Месяц назад +1

      Haha no way. I've been watching his YT vids over the last few days too.

    • @jcorey333
      @jcorey333 Месяц назад

      @@NetNinja I actually got to take his lecture writing class in University (The one that's now online).

  • @riteeshacomputerscience4862
    @riteeshacomputerscience4862 2 года назад

    How many more episodes are gonna be there ? Any ideas ?

  • @kveeeek695
    @kveeeek695 2 года назад

    Hi, I get a 404 when trying to access the github repo. Excellent course btw

  • @engkunasya
    @engkunasya Год назад

    HAHAHA mario adrion😂

  • @arijayaputra216
    @arijayaputra216 Год назад

    Thankyou

  • @keivansf3459
    @keivansf3459 2 года назад

    Amazing

  • @sudarrshang8922
    @sudarrshang8922 Год назад +2

    * Insert One *
    title: "The Way of Kings",
    author: "Brandon Sanderson",
    rating: 9,
    pages: 400,
    genres: ["fantasy"],
    reviews: [
    { name: "Yoshi", body: "Great Book!!!" },
    { name: "Mario", body: "So So..."}
    ]
    * Insert Many *
    [
    {
    title: 'The Light Fantastic',
    author: 'Terry Pratchett',
    pages: 250,
    rating: 6,
    genres: ['fantasy', 'magic'],
    reviews: [
    { name: 'Luigi', body: 'It was pretty good' },
    { name: 'Bowser', body: 'Loved It!!!' },
    ],
    },
    {
    title: 'The Name of the Wind',
    author: 'Patrick Rothfuss',
    pages: 500,
    rating: 10,
    genres: ['fantasy'],
    reviews: [{ name: 'Peach', body: 'One of my favs' }],
    },
    {
    title: 'The Color of Magic',
    author: 'Terry Pratchett',
    pages: 350,
    rating: 8,
    genres: ['fantasy', 'magic'],
    reviews: [
    { name: 'Luigi', body: 'It was OK' },
    { name: 'Bowser', body: 'Really good book' },
    ],
    },
    {
    title: '1984',
    author: 'George Orwell',
    pages: 300,
    rating: 6,
    genres: ['sci-fi', 'dystopian'],
    reviews: [
    { name: 'Peach', body: 'Not my cup of tea' },
    { name: 'Mario', body: 'Meh' },
    ],
    },
    ];