In this course we will build a simple application to show how to perform full CRUD (create, read, update, delete) operations within Node.js.
We'll be using the Node module MongooseJS. Mongoose allows us to define our models in the form of a schema, along with a simple to use API that abstracts away a lot of the pain of working directly with the MongoDB driver.
First, we will create a Book schema using MongooseJS. We will use string data types to add a title, author and description. Next, we will build a simple server using Express.js. Then we will build 4 routes to query, update and delete Books from our Schema. We will use Postman to perform actions on these routes and check the results in our browser.
What You Will Learn
Welcome to the course!
This video covers the basics of what Mongoose is and how we use it.
Mongoose provides a straight-forward, schema-based solution to model your application data. It includes built-in type casting, validation, query building, business logic hooks and more, out of the box.
In this video we learn how to create a Mongoose Schema. Then we'll discuss the different data types and how to export a Mongoose Model so its available to use in other files.
Start building our mini-app that will be able to perform create, read, update and delete operations.
We'll be using a Mongoose Book-Schema along with Express to query objects and display results.
Learn how to use the findOne() method to retrieve just one book.
How to use the req.params method for retrieving a single book
And how to create a single book route that accepts a /:id parameter to grab a single book that corresponds to our _id Model.
This video will cover how to create new Books using the POST method. We'll be using Postman to demonstrate how to how to add a new Book to our model.
This video will cover how to update and delete Books using the findOneAndUpdate method and the remove method. We'll be using Postman to demonstrate how to how to update and delete a Book.
First we'll find() a book passing in the _id parameter for the book, then we'll update or delete this book.