Mongoose JS Tutorial – 3 – Build a CRUD App (1)

Full Course:

Build a mini app using Express and Mongoose.

Learn How to us the find method to query for results.

– In the last video we learned a little bit Mongoose – including how to create Schemas and set up a connection.

– In this lecture we’ll start using mongoose along with express to query objects and display results.

– We’re going to be building a mini app for this project. So start by navigating into a folder where you want your app to be. We’ll start off with npm init to create a package.json file for us.

– Now we’ll install express, mongoose and body-parser

– Next, we’ll build out the BookSchema

– setup app.js and server + test server

– try connecting to mongoose for fail
– now connect to mongod

– Now lets add some books using our shell, connecting to our db and inserting them

– I want to fetch all the books using Express. So we’ll be using app.get in our app.js file to retrieve all the books we added as well as individual books.

– We’ll get into more detail on how to use express in later videos and I also have a free Express Fundamentals course that covers the basics you can check out.

Repo for the code:


  • aldi Wijaya

    how do u create the example database?? and when i code node app i got a missing schema error shema hasn't been registered as a model

  • Mahmoud ibrahim

    in 7:40 my db example has no collections like you has
    are you made it or there's prev version for it

  • rickdps

    I am using an mLab database that has no collections. I am trying following your tutorial but the collection is not being generated automatically. Any thoughts? … Thanks for the series.

  • Meryem Yanar

    By the way, except for getting back an empty [ ] JSON response, this video has helped me more in a few minutes than the past several days of trying to learn this from written materials. THANK YOU and I will be watching all of your videos.

  • Meryem Yanar

    How exactly do you connect your database to your app? I have tried doing what you show in the video, but I get a blank JSON response back, even though I know the DB is not empty and I can run mongo in the terminal to see all the data in it.

  • mayank singh

    is it compulsory to use mongod command when working with mongoose ? i didnt use it when working with mean authentication application with mongoose but when i use mongod it says not recognized

  • preeeby

    Add a message to fix the mistake in video , I spent 30minutes trying to debug error with "Books not being created"!

  • Mote Zart

    I created the books (I call them Products) in the DB, and I have a model. When I call it to the '/products' route, I get the following warning, and the data does not display on the screen.

    DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead:"

    I have no promises here. Only the code U use. I wouldn't care about the warning, but it's making the data not display for some reason.

  • candh

    When I write the code for BookSchema in the Book.model.js and connect to the database and all that stuff, the collection does not gets created. when I run "use example" and when I run "show collections" there's nothing there. However I can make a collection with db.createCollection('collectionName') but you didn't do that. Is it necessary to do this first? Is there no way we can make this using code? or is something wrong?

Leave a Reply

Your email address will not be published. Required fields are marked *