Nest.js with MongoDB - Complete Example

Поділитися
Вставка
  • Опубліковано 3 лип 2019
  • Connect your NestJS app to a MongoDB server and learn how to create, read, update and delete (CRUD) data.
    Join the full "MongoDB - The Complete Developer's Guide" course: acad.link/mongodb
    Exclusive discount also available for my "Node.js - The Complete Guide" course: acad.link/nodejs
    Check out all our other courses: academind.com/learn/our-courses
    ----------
    Watch the first part: academind.com/learn/node-js/n...
    Starting Code: github.com/academind/nestjs-i...
    Finished Code: github.com/academind/nestjs-i...
    MongoDB Introduction: academind.com/learn/mongodb/c...
    SQL vs NoSQL: academind.com/learn/web-dev/s...
    ----------
    • Go to www.academind.com and subscribe to our newsletter to stay updated and to get exclusive content & discounts
    • Follow @maxedapps and @academind_real on Twitter
    • Follow @academind_real on Instagram: / academind_real
    • Join our Facebook community on / academindchannel
    See you in the videos!
    ----------
    Academind is your source for online education in the areas of web development, frontend web development, backend web development, programming, coding and data science! No matter if you are looking for a tutorial, a course, a crash course, an introduction, an online tutorial or any related video, we try our best to offer you the content you are looking for. Our topics include Angular, React, Vue, Html, CSS, JavaScript, TypeScript, Redux, Nuxt.js, RxJs, Bootstrap, Laravel, Node.js, Progressive Web Apps (PWA), Ionic, React Native, Regular Expressions (RegEx), Stencil, Power BI, Amazon Web Services (AWS), Firebase or other topics, make sure to have a look at this channel or at academind.com to find the learning resource of your choice!
  • Наука та технологія

КОМЕНТАРІ • 195

  • @michaelpeltz
    @michaelpeltz 5 років тому +10

    Excellent as always Max. Not a waisted syllable. Dilligent preparation. Your commitment to researching and using best practices on every level is greatly appreciated. People: if you haven't taken any of Max's Udemy courses I highly recommend them. There are always sales and Max often includes a discount link in these free vids. I don't think I've paid more than $12.

  • @belindabaumgartner4639
    @belindabaumgartner4639 5 років тому +10

    Thank you for this great course and please keep adding more NestJS courses!

  • @disapamok_
    @disapamok_ Рік тому

    Great one! I always find something new while watching your tutorials, And the way you present is precious! Thanks Max.

  • @johnschmidt874
    @johnschmidt874 5 років тому

    Thanks Max! You always post top-notch quality, both on video and the content.

  • @kerryd2060
    @kerryd2060 5 років тому +66

    You're my favorite instructor on Udemy. I'm in most of your Udemy courses including MongoDB & NodeJS. You make the subjects easy to understand. Thank you!!

    • @academind
      @academind  5 років тому +1

      Thanks for this wonderful feedback and your great support Kerry!

    • @daltonjameson1506
      @daltonjameson1506 3 роки тому

      I know Im pretty randomly asking but do anybody know a good website to watch new series online ?

    • @korbinfox2878
      @korbinfox2878 3 роки тому

      @Dalton Jameson Try flixzone. You can find it by googling :)

  • @venkatakameshwarpeddada1558
    @venkatakameshwarpeddada1558 4 роки тому +1

    Thanks, both the videos w.r.t NestJs were quite useful. It helped me a lot to know about NestJs framework and become hands on very easily.

  • @NoumanAhmed2405
    @NoumanAhmed2405 Рік тому

    I am watching it after 3 years. you are always my favorite.

  • @riverofcustard3233
    @riverofcustard3233 4 роки тому

    Thank you for this minicourse. NestJS is a super cool addition for a project.

  • @kingdarboja7903
    @kingdarboja7903 5 років тому +1

    Awesome tutorial, glad you made this one to show us how to deal with non-sql engines. Pretty much what developers needed besides the great documentation at NestJS page. However, I know there is other way of using MongoDB on our NestJS project, and that is TypeOrm. Would be great if you can show us the same approach in another tutorial.
    CHEERS!

  • @aminazgol3918
    @aminazgol3918 Рік тому

    Excellent tutorial sir, I really like your coding practices. Clean and professional

  • @miago4155
    @miago4155 5 років тому

    Thank you very much for this further, excellent, free course.
    You doing great.

  • @BDominikGT
    @BDominikGT 4 роки тому +1

    Absolutely amazing tutorial, like always. Excelent job. Thank YOU.

  • @ITEducationPakistan
    @ITEducationPakistan 4 роки тому

    Max you are my best instructor forever..
    Your research and teaching efforts for everyone both are begginer or professional and specifically your interaction with student joyful to learn something new with interesting and your theoretical logic for explanations make me easier to understand.

  • @reddyakanksha98
    @reddyakanksha98 2 роки тому

    Thanks for the clean & clear tutorial, helps a lot..🙏

  • @imranali3800
    @imranali3800 3 роки тому

    Thanks Max for the amazing tutorial and nice explanation of each and every concept crystal clear.

  • @brahimwebmaster
    @brahimwebmaster 5 років тому +1

    Thank you Max, this is what I'm looking for 👍👍👍👍

  • @user-ur2ft7hp7t
    @user-ur2ft7hp7t 5 років тому +6

    Hello, Max. Thank you for your work! It's a great stuff and useful much. Once you've asked about what would we like you make a course about? Well, I'm sure that your audience is mostly full stack developers. And as we all have a desire to grow we'd like to be aware of all aspects of development and delivery features to the customers, well at least most of them. I think devops is very interesting topic we all are interested in, especially Kubernetes. It would be great if you make a complete course about it. One more thanks for your videos.

  • @therhythmatic
    @therhythmatic 4 роки тому

    Nice video, much appreciation to you Max for sharing with us! You always level us up!

  • @yinonelbaz5309
    @yinonelbaz5309 11 місяців тому

    Very helpful guide!
    You are a true professional!

  • @rakshithg7337
    @rakshithg7337 5 років тому +1

    Hey Max you rock while teaching
    Wonderful instructor 💯
    infact I was looking for nestjs combo of mongodb

  • @batuhanbag5054
    @batuhanbag5054 2 роки тому

    Amazing tutorial ever about Nestjs, I am glad for this. Thanks for everything

  • @muhammadarslan9939
    @muhammadarslan9939 Рік тому

    Thank you. great series learned a lot.

  • @pedromanuelcamargomendez6520
    @pedromanuelcamargomendez6520 4 роки тому

    Excellent Contribution. Thank you.

  • @arnonaf
    @arnonaf 4 роки тому +3

    There is a critical gap here that I don't understand how it is not shown/happening in your video - the Product class actually has to be an interface that extends "mongoose.Documet", otherwise you get a red error in the service ctor underlining because "Type 'Product' does not satisfy the constraint 'Document'".
    Why it doesn’t it reproduce here?

  • @kirillbaryba746
    @kirillbaryba746 5 років тому +1

    awesome, thanks more NestJS!

  • @joerivde
    @joerivde 2 роки тому

    So you're from München. Excellent tutorial, as always. Much love from your Belgian neighbours (:

  • @thedupy124
    @thedupy124 3 роки тому

    Incredible video, thanks for all !

  • @aram5642
    @aram5642 4 роки тому +2

    Fantastic primer, Maximilian! Thanks a lot! I learned a lot about mongoose. Do you think you could make yet another video about working with relations? Say, products assigned to Categories. Would you make categories a separate module in Nest app?

  • @hosnisuazo757
    @hosnisuazo757 5 років тому

    Thanks man I always learn with your courses!

    • @academind
      @academind  5 років тому

      Awesome to read that Hosni, thank you for your comment!

  • @babakdarafarin9065
    @babakdarafarin9065 3 роки тому

    Thank you very much. Your video helped me a lot.
    Best wishes

  • @NorseJedi
    @NorseJedi 3 роки тому +28

    Just for anyone else running into this problem with newer versions of mongoose, the Product interface in product.model.ts has to extend the Document interface from mongoose.
    So instead of:
    export interface Product
    You'll need to put:
    export interface Product extends mongoose.Document

    • @TheLukrify
      @TheLukrify 3 роки тому +2

      U saved me of lot of google searching. BIG THANKS!

    • @pervyshrimp2860
      @pervyshrimp2860 3 роки тому

      thanks a lot man legit helped

    • @LattE0825
      @LattE0825 3 роки тому

      Damn i've been scrambling here for hours, wondering what I have missed on the tutorial. Thank you so much!

    • @sahibsingh1221
      @sahibsingh1221 3 роки тому

      Got the same issue, resolved. Big Thanks.

    • @lucaszanek6204
      @lucaszanek6204 3 роки тому

      Thanks!!!!!

  • @hbela1000
    @hbela1000 4 роки тому

    Thanks a lot, definitely the best intro with github source.Would be great to have a NestJS Complete Guide too, including maybea little side note on NestJS/Firebase too.

    • @academind
      @academind  4 роки тому

      Thank you, got no plans regarding a Complete Guide on NestJS at the moment though.

  • @binodnepali
    @binodnepali 5 років тому

    I was hoping this video. Thank you Max

    • @binodnepali
      @binodnepali 5 років тому

      Hi Max, Can you answer the below questions?
      When we perform CRUD operation on the database, I am a bit confused about managing the data in the application.
      Currently, What I do is, when I fetched a list of data from the database I stored in the memory in the list and when I want to add new data, first I saved the data in the database if the saving was successful then add to my memory list (which is the same list that I have when I have fetched the data) same follows for updating and deleting a data.
      Is this a correct way to do? or I need to do another way around which is fetching (querying the database) the data from the database every time when I add, update and delete a data. Which is one is an optimal solution?

  • @bikramgyawali7292
    @bikramgyawali7292 2 роки тому

    babbal tutorial yrr thikai xa.thanks from year 2021.This video dosent knows what 2020 is bringing home hahah.lol

  • @donikastoqnova1734
    @donikastoqnova1734 11 місяців тому

    Again amazing course.

  • @anishkodishala8210
    @anishkodishala8210 4 роки тому

    Thanks Max. Amazing tutorial. It would be great if you can add another video on using Swagger and JEST to test the NEST JS application.

  • @Black1Sabbath100
    @Black1Sabbath100 4 роки тому

    Thanks a lot max!! your a hero!

  • @compncheese8358
    @compncheese8358 Рік тому

    Thank you so much sir.
    Some critical feedback: Whenever you complete a task, show it running or atleast test it to make sure you have done it properly. Rather than completing task 'a' and moving to task 'b' only to find task 'a' not working when you completed task 'b', run task 'a' as soon sa you have finished it and are moving to the next big topic :)
    [Below is an example, no need to read if you get my point]
    When you were connecting to the mongodb 8 mins into the video, it was only at 18:34 you realized there was a problem with the connection. This makes the learning process a bit bumpier than usual. And may bring confusion to others. Thank you :)

  • @KamranTanveer-lm5et
    @KamranTanveer-lm5et 2 місяці тому

    that was very helpful...
    thank you

  • @eddzmaciel
    @eddzmaciel 3 роки тому

    THANK YOU VERY MUCH FOR YOUR KNOWLEDGE

  • @juliecherner9085
    @juliecherner9085 2 роки тому

    Excellent, thank you for amazing work and clear explanations!

  • @przemysawwronski5738
    @przemysawwronski5738 5 років тому +60

    NestJs course would be great

    • @academind
      @academind  5 років тому +2

      Not planned in the near future, sorry :/

    • @adriannlara
      @adriannlara 5 років тому

      @@academind U_U

    • @un256ix
      @un256ix 5 років тому +2

      using CQRS pattern and even better if in nx workspace together with angular :D

  • @raimundoladrondeguevara8597

    Thank you for this video.

  • @wcyoutube
    @wcyoutube 5 років тому

    This is great! Good stuff to practice full stack development.

    • @academind
      @academind  5 років тому

      Happy to read that Cha, thanks a lot!

  • @dhiliph98
    @dhiliph98 5 років тому

    Thank You Max!!

  • @sttpt
    @sttpt 4 роки тому +1

    Thanks Max for this great session. I have one question - If mongoose provides id of the product as product.id (without underscore), why doesn't it return the product with id instead of _id? This would have saved the transform/map?

  • @Ollinho12
    @Ollinho12 5 років тому

    You maniac, giving this a watch now.

  • @wassimmehanna4402
    @wassimmehanna4402 2 роки тому

    This 5 stars tutorial needs a continuity with one to many relationships using mongoose. I would glady pay for this.

  • @radovansurlak7445
    @radovansurlak7445 3 роки тому

    Thank you Maximillian! :)

  • @HaiderAli-co9jl
    @HaiderAli-co9jl 4 роки тому +1

    Please make a bonus deployment video Max. Maybe on Heroku, that will be great.
    Thanks for all these great tutorials

  • @basilirzhak4276
    @basilirzhak4276 3 роки тому

    Thanks mr. MAX!

  • @Abhishekn._
    @Abhishekn._ Рік тому

    thanks for the tutorial

  • @tuku_mann
    @tuku_mann 2 роки тому

    Very very useful actually in the middle 2022 as well

  • @JuanTeDDi
    @JuanTeDDi 3 роки тому

    awesome, thank you so much!

  • @noskap
    @noskap 4 роки тому

    This is awesome!

  • @ishanbhawantha
    @ishanbhawantha 3 роки тому

    Thank you verymuch!!

  • @kh1amirhamza
    @kh1amirhamza 3 роки тому

    Thank you so much!

  • @samywat
    @samywat 3 роки тому

    thanks for this!

  • @titobundy
    @titobundy 3 роки тому

    Is good practice map result to dto when your query return only some of fields of the document or from many collections? For example when we use aggregate

  • @fallen0ne7
    @fallen0ne7 3 роки тому

    thanks a lot dude!

  • @vceolin3908
    @vceolin3908 3 роки тому

    AWESOME VIDEO

  • @taniusahincu3119
    @taniusahincu3119 4 роки тому +1

    Great Tutorial Max. Now you must add NestJs + MongoDB + Socket.IO and will be the nice tut. again! Thx!

  • @IndianRailwayLovers
    @IndianRailwayLovers 3 роки тому

    Got this issue in product service file on constructor line. "Type 'Product' does not satisfy the constraint 'Document'." Please help me out @Academind

  • @tanvironair
    @tanvironair 4 роки тому

    at 20:58 how it's returning result.id? when the mongo/mongoose field name is _id. what I'm missing?

  • @ishraq95
    @ishraq95 4 роки тому

    Today I knew about netjs..I think its great for Angular Dev like me..

  • @fransyosua5433
    @fransyosua5433 2 роки тому

    hi Max, it's 2021 and I just following your nestjs tutorial. When I install the @nestjs/mongoose and mongoose it's fine, but when I change the app.module.ts to connect my mongodb, it's showing an error
    /home/frans.yosua/Documents/Kerjaan/Project/nestjs-intro/node_modules/mongodb-connection-string-url/node_modules/whatwg-url/dist/encoding.js:2
    const utf8Encoder = new TextEncoder();
    ^
    ReferenceError: TextEncoder is not defined
    what do I miss?

  • @cristiancontreras2924
    @cristiancontreras2924 5 років тому

    Excelente!!!

  • @abhishekbandekar7884
    @abhishekbandekar7884 4 роки тому

    Thank You Sir

  • @Booshwong
    @Booshwong 2 роки тому

    i don't understand, I keep getting a connection error when trying to connect to mongodb atlas, with mongoosemodule. It says the uri is undefined, however I am providing the string directly and not with a .env

  • @jo0o0oke3e3er
    @jo0o0oke3e3er 5 років тому

    Hey Max, how are you doing? are you offering or do you have any plan about a nestjs course?
    thx

  • @omartarek9032
    @omartarek9032 4 роки тому

    Thanks max, I LOVE NestJS. for me it makes everything easier and more organized :D
    Can you please add a course about passport.js to use in our apps? :D

  • @benwerbowyj5700
    @benwerbowyj5700 4 роки тому +1

    Does the interface you show for the "Product" at 15:00 need to extend the Document interface from Mongoose?
    I get an error when trying to use it as the Model type in the service file if I don't include the "extends Document" when defining the interface.
    EDIT: I think it's related to the @types/mongoose npm package

    • @weronika0515
      @weronika0515 3 роки тому

      Found an answer here: github.com/DefinitelyTyped/DefinitelyTyped/issues/33824#issuecomment-609642686

  • @kuberasamrat143
    @kuberasamrat143 4 роки тому

    How do we map dto to mongo schema? If the naming conventions are different. For eg: Spring framework provides this library. "mongodb.core.mapping.Field". Is there anything in Nest JS?

  • @skyzane2735
    @skyzane2735 Рік тому

    @academind Ssems like there is a newer implementation of nestjs and mongoose. Like using decorators such as @Prop. Do you have that video? Please let us know.

  • @matheusmgp1
    @matheusmgp1 2 роки тому

    Max always the best

  • @vkmucheti
    @vkmucheti Рік тому

    thank you max a great beginning to nest with mongoose but is it possible to connect to a angular application to post get update delete data, mean need a video on angular + nest with mongoose

  • @rafa_hd
    @rafa_hd 4 роки тому

    Hi Max. What about Adonis? Have you used or tried? Thanks.

  • @jediampm
    @jediampm 5 років тому +1

    Thanks Max, as always great video.
    Somethings to point out:
    - as you know, when you choose to work promises with async/wait sintaxe, you should warp inside try/catch.
    - in methods like update / insert or delete, you should return at least the status code of 201.
    - why not to use TypeOrm ?
    And to finalize, as soon as possible bring a video abou loopback 4. Thanks ;)

    • @dakshsagar2839
      @dakshsagar2839 5 років тому

      TypeORM is for SQL databases .

    • @miago4155
      @miago4155 5 років тому

      all those things nestjs does for you. and I think thats beautiful.
      @daksh sagar You can use typeOrm with mongodb. But you are right that the advantages of typeorm can be better exploited with sql databases.

    • @jediampm
      @jediampm 5 років тому

      @@dakshsagar2839 TypeOrm, it is not only to SQL type DB, also it works with No SQL DB.
      links:
      docs.nestjs.com/techniques/database
      typeorm.io/#/mongodb

  • @ZeWitchKid
    @ZeWitchKid 5 років тому +1

    waiting to buy that nest js full course

    • @academind
      @academind  5 років тому

      No plans to create such a course in the near future, sorry.

  • @HuyKon
    @HuyKon 2 роки тому

    How can I move all configs (database, host, port, ..) to a env file?

  • @tipsharp6494
    @tipsharp6494 5 років тому

    Again amazing 10x max

  • @kakhabervk9405
    @kakhabervk9405 2 роки тому

    This is fine contintue of previous tutorial, only thing is that, I tried to keep old version as possible with node version 10 LTS, mongoose@5 and @nestjs/mongoose@6 and @types/mongoose, but after update product script gets error . In my situaton I removed @types/mongoose and updated to mongoose@5.13.14 and @nestjs/mongoose@7.2.4.

  • @mustaneerhaider515
    @mustaneerhaider515 Рік тому

    It would be if you release where you build an authentication api with jwt tokens using nestjs and mongogdb. Thanks for this and the previous videos. Your explanations are always awesome and easy. Still waiting for your nestjs course on udemy as i already have done your nodejs course from udemy in the past.

  • @despertaweb4793
    @despertaweb4793 3 роки тому

    It would be great if you could expand this tutorial with nested documents, and some of the best approaches (embedded vs reference)

  • @ferditiger4665
    @ferditiger4665 2 роки тому +1

    44:25 There is no "result.n" propertiy for delete operation anymore. It returns deletedCount property. So if case should be like this : if(result.deletedCount ===0)

  • @ahmedsafan86
    @ahmedsafan86 4 роки тому

    Thanks

  • @alon.galperin
    @alon.galperin 5 років тому

    Great video!
    I have a question:
    If you want to add functions to the model like a function that returns a string of firstname + lastname. How you are doing it and exposes this?
    thanks Alon

    • @teolag
      @teolag 5 років тому +1

      You can create a mongoose virtual and then add it to the interface.
      mongoosejs.com/docs/guide.html#virtuals

  • @user-xj2xs3mz9v
    @user-xj2xs3mz9v 4 роки тому

    amazing

  • @sumitvishwakarma452
    @sumitvishwakarma452 5 років тому +1

    Hi Max,
    This looks so cool...What is the future of nest.js if someone planning to learn. I have already expertise in Angular + .net.
    I am thinking to learn Node.js(MEAN Stack).

  • @kishorebabumadasu4235
    @kishorebabumadasu4235 5 років тому

    Hi Max, your courses simply excellent. Ref: npm install --save mongoose @nestjs/mongoose.

  • @TheFayt11
    @TheFayt11 5 років тому

    Mr max ! Could you explain about Angular error "ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked" ? I already read the article but i still dont quite understand. Please help if you have some free time ! Thank you so much mr max ! it means a lot ^ ^

  • @julleu8847
    @julleu8847 4 роки тому

    At 36:50 I ran into a Problem. In the Project im working on we use shared entities and the frontend guys don't want to deal with mongoose imports obviously. I worked around this by simply removing the returntype from the findProductById-Method. No @types/mongoose needed.

  • @srinaths2361
    @srinaths2361 4 роки тому

    Hi..Great course..i had a small doubt.. How to implement cucstom id using mongodb in nestjs?

  • @javaadpatel9097
    @javaadpatel9097 4 роки тому

    could you also explain how to unit test this product service?

  • @sameeravhad6266
    @sameeravhad6266 2 місяці тому +1

    Hi, I have one doubt. How mongodb created collection (table Name) name "Products" ? Where are we defining in code base ?

  • @Heiko_Kanzler
    @Heiko_Kanzler 4 роки тому

    If you're starting from ground, you end up in lot's of issues with VSCode, TypeScript and thus. Return types missing, not compiling without return types... Had similar challenges with the first part of the course, but that was easier to fix, but this is harder if you're new to the topic :-( Perhaps because of changes in nest.js and mongoose? I downloaded the sources and started with them now, and they seem to work, however except the dependencies, my code is identical (up to minute 18:40).

  • @pradeepkumar-pi4lj
    @pradeepkumar-pi4lj 4 роки тому

    Do you have any vedio on nestjs mongodb user authentication using jwt token

  • @alexanderommm
    @alexanderommm 5 років тому

    Why do you return Promise in service and then you use in controller async func to get Promise again. You can just return promise. Nest will resolve it.

  • @shantitripathy7757
    @shantitripathy7757 3 роки тому +4

    Could you provide an update to the video based on the new decorators that are suggested in nestJS document like @Schema(), @Prop()? That will be very helpful

    • @Elfein
      @Elfein 2 роки тому +1

      bumping into your comment made my life a lot easier :)

  • @getdevotional
    @getdevotional 2 роки тому

    I'm not sure how the 'products' collection got created in Mongo DB. Database name was mentioned in the config but not collection name