Superfilter AI
Course Description
MongoDB is the leading open source NoSQL database. In this course you'll build schemas, structure models and learn to query MongoDB to get the right data. Learn the core concepts to build production-ready applications with MongoDB!
This course and others like it are available as part of our Frontend Masters video subscription.
Preview
CloseLearn Straight from the Experts Who Shape the Modern Web
Your Path to Senior Developer and Beyond
- 200+ In-depth courses
- 18 Learning Paths
- Industry Leading Experts
- Live Interactive Workshops
Table of Contents
Introduction
Section Duration: 16 minutes
- Scott gives a quick tour of the Github repository, and what the course will contain. Instructions are also given for how to download MongoDB, how to start the Mongo database server locally, and an introduction is given for the Compass GUI.
- A question is asked about the benefits of using Mongo, the ideal use cases, and types of data storage offered by Mongo.
Mongoose
Section Duration: 44 minutes
- Scott gives an overview of what will be covered in the course. Rationale for utilizing Mongoose is also given.
- Scott introduces the process for requiring Mongoose, what port to explicitly bind to, how to connect locally, and how to manage warnings in the terminal stemming from mismatched Mongoose and MongoDB versions.
- Scott instructs on how to create a simple schema and model.
- Scott begins writing operations against the database, then executes the file that was created.
- Scott reviews what the object id is, the versioning of Schemas in the Mongoose document, and the difference between a Mongoose document and a JavaScript object. A question is also asked regarding how Mongoose differs from Mongo.
- Scott goes into greater detail about validation, and adding fields.
- Scott demonstrates how to do several simple queries, such as finding a specific entry by field, finding an entry by ID, finding and updating by entry ID, and creating a timestamp field.
- Scott instructs students to complete the exercise in which the goal is to create connection logic and Mongoose schemas. Using the schema, students create CRUD functionality.
- Scott live codes the solution to schema portion of the exercise.
- Scott live codes the solution to CRUD portion of the exercise, and explains why it's important to use .exec() at the end of queries.
Associations
Section Duration: 47 minutes
- Scott demonstrates how to reference a model with a foreign key, and explains how this is saved differently than in SQL.
- Scott demonstrates how to use populate to build virtual join tables.
- Questions are asked about the ._id property, adding another document to the existing parent document,
- Scott gives an overview of some ways that filters and modifiers could be used to manipulate entries.
- Scott instructs students to complete an exercise with the goal of creating relationships between models. The models will then be utilized to create more advanced queries than the previous exercise.
- Scott live codes the solution to the exercise.
- Scott live codes the final query that adds posts to existing posts, instead of wiping them away.
Virtuals, Hooks & Indexes
Section Duration: 37 minutes
- Scott gives an overview of what a virtual is, then live codes an example.
- Scott discusses how to utilize pre-save, pre-validation, and post-save middleware, among many available. An example is given on making the code asynchronous, and Scott answers a question about how the library determines that the code is asynchronous without using flags.
- Scott discusses how index allows the user to go straight to the value, and the benefits of doing so.
- Scott introduces compound indexes as a way to introduce scope to fields.
- Scott instructs students to complete an exercise with the goal of utilizing schema middleware, hooks, and indexes.
- Scott live-codes the solution to the previous exercise.
APIs
Section Duration: 57 minutes
- Scott begins to live code a basic API server that uses an event-based Node.js framework to grab notes from a server.
- Scott introduces cursor based pagination and skip limit based pagination. An example of how to implement skip limit pagination is demonstrated.
- Scott live codes the API server to post a note, and return the note after it's created.
- Scott shows how to return a JSON object when a Mongoose object isn't required. Whether to start the server before connecting to the database is also discussed.
- Scott demonstrates how to run the Express server that was just created, and takes questions from students.
- Students are instructed to write several controllers. Insomnia is introduced as a tool to construct http requests.
- Scott live codes the solution to the previous exercise.
- Questions are asked about how to prevent a server from dying, using the same code on the frontend, and progressive web apps are briefly discussed.
- Questions are posed about memory usage, transactions, and writing the same data from multiple sources.
- Questions are posed about how to structure your data in Mongo, benefits of denormalizing data, general questions about how to architect databases, and if it's possible to mix databases.
- Scott goes over key tools to explore beyond the scope of this course.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops