📄️ Intro
Using hard-coded values on our API is nice, but chances are you'll want to persist this data in the future. In this section, we'll learn how to use a database to store our data.
📄️ Adding data to MongoDB
Before we connect to our MongoDB database, we need to add some data that we can query. We will do so using the Atlas UI.
📄️ Connecting to the database
We'll be using the MongoClient class to connect to our database.
📄️ Retrieve all documents
Let's now change the get route to retrieve all documents in the collection.
📄️ Get working!
Time to draw the rest of the f'ing owl.
📄️ Solutions
Hopefully you've had a chance to try the exercises above. Here are my solutions.
📄️ 🦸 Advanced - Clean up your code
When you build your API, you will probably have a lot of code. It's important to keep your code clean and organized.