Anastasia Lanz's Blog

MongoDB

November 19, 2021

I have a new side project idea to make a website that shows warranties for different outdoor gear companies. In my house, we have a whole room full of gear for hiking, backpacking, climbing, and cycling. Sometimes things break and it would be nice to look up a brand to easily find their warranty information along with any info about repairs.

For this project, I am using Next.js, TypeScript, and MongoDB for the database. I chose MongoDB because I haven’t worked with it on a client project yet and I wanted to learn something new.

When browsing around the MongoDB website, I learned that there is a MongoDB University where I enrolled in the Developer Learning Path. The first course is called “MongoDB Basics” and it’s all about the fundamentals. As I’m going through the course, I’ve been thinking about how I want to set up collections and documents for my project.

MongoDB Developer Learning Path

Collections and Documents

Collections are where you store documents in MongoDB. You can have many collections in a single database. As an example for my project, I could make a companies collection that has many documents for each company.

An example of a company document would look like this:

{
  "_id": 1,
  "company": "REI",
  "url": "https://www.rei.com/",
  "warrantyTypes": [
    "One year after purchase",
    "90 day for outdoor electronics"
  ],
  "warrantyUrl": "https://www.rei.com/rei-difference"
}

There are few important things to note about documents:

  • The "_id" is a unique identifier for this document
  • There can be identical documents only if the "_id"’s are different
  • Each document in a collection can have different schema

Still Learning

I’m still going through the basics of MongoDB and I have until January to finish this course. The goal by the end of the month is to have an MVP database that I can then hook up to my Next.js app.


Profile picture

Written by Anastasia Lanz who lives and works in Laramie, Wyoming. You should follow her on Twitter