This is where we officially begin to make the Rest APIs youโre creating useful.
You will learn to:
- Setup Mongoose (a better way to manage MongoDB) in your project.
- Create users and save them to the database
- Use your Rest APIs to create, read, update, and delete users (CRUD).
Weโre using real databases here because all useful Rest APIs talk to databases. If they donโt, your information will not be saved, and in most instances, the connection will be redundant.
Source Code
Hereโs a link to the Github Repository.
Timestamps
- 0:00 Introduction to databases
- 1:30 Recap from previous session
- 5:30 MongDB vs Mongoose
- 7:00 Creating Mongoose models and schemas
- 11:30 Adding Data into into the models
- 14:00 Adding data in a route
- 17:30 Generic structure of an API
- 22:07 Using Thunder Client (alternative to postman) to send requests
- 24:00 Creating a user
- 29:20 Cleaning up Mongoose objects before sending them to the frontend
- 31:11 Getting users
- 38:30 Converting a string into an Mongoose object
- 41:30 Recommended file structure for an Express project
- 42:00 Creating a service layer
- 51:50 Small defensive coding
- 53:15 Setting correct error status
- 56:15 Updating a user
- 1:04:00 Deleting a user
Welcome! Unfortunately, you donโt have access to this lesson. To get access, please purchase the workshop or enroll in Magical Dev School.
Unlock this lesson