Introduction to MongoDB
Table of Contents
Course SetupScott 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.
Mongo Q&AA question is asked about the benefits of using Mongo, the ideal use cases, and types of data storage offered by Mongo.
Schemas & Why MongooseScott gives an overview of what will be covered in the course. Rationale for utilizing Mongoose is also given.
Connecting to the DatabaseScott 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.
Creating Schemas & ModelsScott instructs on how to create a simple schema and model.
Creating a Mongo DocumentScott begins writing operations against the database, then executes the file that was created.
Mongoose SchemasScott goes into greater detail about validation, and adding fields.
Basic Query MethodsScott 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.
Schema & CRUD ExerciseScott 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.
Schema SolutionScott live codes the solution to schema portion of the exercise.
CRUD SolutionScott live codes the solution to CRUD portion of the exercise, and explains why it's important to use .exec() at the end of queries.
Creating Associations with a Nested SchemaScott demonstrates how to reference a model with a foreign key, and explains how this is saved differently than in SQL.
Querying Associations with populateScott demonstrates how to use populate to build virtual join tables.
Querying Q&AQuestions are asked about the ._id property, adding another document to the existing parent document,
Querying with Filters and ModifiersScott gives an overview of some ways that filters and modifiers could be used to manipulate entries.
Associations ExerciseScott 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.
Associations SolutionScott live codes the solution to the exercise.
Add Similar Posts SolutionScott live codes the final query that adds posts to existing posts, instead of wiping them away.
Viruals, Hooks & Indexes
VirtualsScott gives an overview of what a virtual is, then live codes an example.
Middleware Hooks: Pre, Post & AsyncScott 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.
IndexesScott discusses how index allows the user to go straight to the value, and the benefits of doing so.
Compound IndexesScott introduces compound indexes as a way to introduce scope to fields.
Virtuals, Hooks & Indexes ExerciseScott instructs students to complete an exercise with the goal of utilizing schema middleware, hooks, and indexes.
Virtuals, Hooks & Indexes SolutionScott live-codes the solution to the previous exercise.
Use Express to Build a REST APIScott begins to live code a basic API server that uses an event-based Node.js framework to grab notes from a server.
PaginationScott introduces cursor based pagination and skip limit based pagination. An example of how to implement skip limit pagination is demonstrated.
Create a Document on POST RequestScott live codes the API server to post a note, and return the note after it's created.
Mongoose Query OptimizationsScott 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.
Running ExpressScott demonstrates how to run the Express server that was just created, and takes questions from students.
Build a REST API ExerciseStudents are instructed to write several controllers. Insomnia is introduced as a tool to construct http requests.
Build a REST API SolutionScott live codes the solution to the previous exercise.
Running a Server Q&AQuestions are asked about how to prevent a server from dying, using the same code on the frontend, and progressive web apps are briefly discussed.
MongoDB Q&AQuestions are posed about memory usage, transactions, and writing the same data from multiple sources.
Modeling Data Q&AQuestions 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.
Other Mongo Tools & ResourcesScott goes over key tools to explore beyond the scope of this course.