
Welcome to the course! Let me introduce myself and give you a rough overview of the course!
Let's dive into the most important question: What is MongoDB? What is it all about? MongoDB is a NoSQL database and in this lecture, we'll explore why it's awesome!
Learning alone is absolutely fine but finding learning partners might be a nice thing, too. Our learning community is a great place to learn and grow together - of course it's 100% free and optional!
MongoDB has a couple of key characteristics that set it apart from other databases - let's explore which characteristics these are.
MongoDB is more than just a database engine - it's a company and a rich ecosystem of tools. In this lecture, you'll get a thorough overview of all the different pieces that make up MongoDB.
Learn how to install and run MongoDB community server on macOS, use the mongo shell, configure data and log paths, and start mongod from the terminal.
Install the MongoDB community server on Windows using the MSI installer, enable the MongoDB service, and use the mongo shell to show databases.
Install and use the MongoDB shell (mongosh) to connect to your running server, with guidance on Windows and macOS and choosing the newer shell for easier output.
With the MongoDB tools installed, it's time to get started. Let's spin up a MongoDB server (on our local machine) and connect to it!
When it comes to connecting to a MongoDB database, you got various options, most importantly: The local shell or drivers for different programming languages. Let me explain the differences.
We learned about a lot of different pieces that work together - here's a big picture that puts everything into context.
We know what MongoDB is - but what's in this course? In this lecture, you'll get an overview of the course content and the order in which it is presented.
It's important to me that you succeed, hence in this lecture, I'll share some best practices regarding how to use the various course resources.
Explore the core basics of MongoDB, including collections and documents, and master CRUD operations: create, read, update, and delete through practical queries to insert, find, update, and delete data.
Explore how databases, collections, and documents relate in MongoDB, with implicit creation, and learn to connect via the shell using port 27017.
Use the shell to run MongoDB queries and CRUD operations on a local server, then compare language drivers for C++, C#, Java, Node.js, PHP, and Python.
Learn how to create and use databases and collections in MongoDB, switching with use, and inserting data on demand with insertOne using JSON documents.
Learn how MongoDB stores json data as documents within a collection, including arrays of documents, using insertOne, find, and pretty, with key-value pairs, strings, numbers, booleans, and ObjectId _id.
Master create, read, update, and delete operations in MongoDB by using insertOne, insertMany, find, findOne, updateOne, updateMany, replaceOne, and delete on collections.
Explore flight data in MongoDB using find, insert many, deleteOne, deleteMany, and updateOne/updateMany with $set to manage documents efficiently.
Learn how to use insertMany to insert a JSON array of documents into flight data, preserving order and IDs, by pasting the array into the shell and running find.
Dive deeper into MongoDB data queries by applying filters with find, using operators like $gt for distance, and retrieving all matches or a single match with findOne.
Find returns a cursor, not all documents; use forEach or toArray to fetch passengers data, and note shell vs driver differences with insertMany and findOne.
Discover projection in MongoDB to fetch only needed fields, such as name and age, reducing bandwidth by filtering data on the server before sending results.
Explore embedded documents and arrays as core MongoDB features, nesting documents up to 100 levels and respecting a 16 megabyte document size, with arrays holding any data.
Update all flight records by setting a new embedded status document using updateMany with an empty filter, adding nested fields like description, lastUpdated, and details with a responsible person.
Explore using arrays in MongoDB by updating a passenger record to add a hobbies array, which can hold strings, numbers, or even documents; learn that arrays can nest within documents.
Wrap up the module by reviewing MongoDB's layered data model of databases, collections, and documents, including _id, embedded documents, and arrays, plus CRUD, find with cursors, and projections.
Model data in MongoDB by designing document schemas, choosing data types like text, numbers, and dates, and reflecting relations between posts, users, and comments.
Explore how MongoDB remains schema-less, letting different documents coexist in one collection, while you still enforce a practical schema so apps can reliably access fields like name and price.
Explore how MongoDB documents use flexible schemas, balancing a core name and price with optional details, including null values, across chaos world, middle world, and SQL world.
Explore MongoDB data types, including text, booleans, int32 and int64 numbers, NumberDecimal, ObjectId, ISODate and Timestamp, plus embedding documents and arrays for flexible schemas.
Explore MongoDB data types in action, including strings, booleans, numbers (including int32), embedded documents, arrays, dates, and timestamps, using the shell and Node.js driver APIs.
Plan your data structure by identifying what data your app needs and how it will be stored in collections and documents, aligning schemas with how you fetch and display data.
Explore how to model relations across multiple collections in MongoDB by comparing embedded documents and references, and discuss when to use each approach for related data.
Explore one-to-one relations in MongoDB by comparing reference vs embedded disease summaries for patients, highlighting embedded documents for fast single-query access and simpler data retrieval.
Explore one-to-one relationships in MongoDB by comparing embedded documents with separate collections, highlighting when to use references for analytics and selective data access.
Explore one-to-many relations in MongoDB by embedding answers in a question thread, or using a separate answers collection with references, and fetch merged data efficiently.
Split large one-to-many data into separate collections by referencing citizens from a city, to avoid embedding and the 16 megabyte document limit, enabling selective city metadata retrieval.
learn how to model many-to-many relationships in mongodb using references across two collections or by embedding orders in the customer document, weighing data duplication and snapshot needs.
Learn to model many-to-many relations in MongoDB by using references with object ids, keeping author data up to date across books and improving write performance.
Explore embedded versus reference relations in MongoDB, covering one-to-one, one-to-many, and many-to-many. Consider data size, change frequency, nesting limits, and the 16-MB document cap.
Merge related documents in one step with the lookup operator using the aggregate method, joining books with authors by local field authors and _id, aliasing results as creators.
Plan a MongoDB schema for a blog with users, posts, and comments, and model their relations. Embed comments in posts, keep users in a separate collection to avoid duplication.
Understand schema validation in MongoDB to lock down flexible schemas, enforce data types like title strings, and control inserts and updates with strict or moderate validation.
Learn how to add collection document validation in MongoDB using createCollection, configure a validator with a json schema, and enforce required fields and bson types like ObjectId for posts.
Learn to modify collection validation with db.runCommand and collMod, set a validator and validationAction from error to warn, and understand how this affects inserts.
This wrap-up reviews data modeling and structuring for MongoDB. It compares embedding and references, and considers fetch frequency, duplicates, relations, and schema validation to ensure valid data.
Explore how to start MongoDB as a process or a service, discover configurable options, and learn basic configuration and troubleshooting guidance to manage the server.
Explore the official MongoDB docs to learn server features, installation steps, and the Mongo shell; start the server with mongod, connect with mongo, and use --help to view options.
Configure MongoDB storage and logging with --dbpath and --logpath, directing data files and logs to chosen folders and enabling persistent audit trails.
Explore mongod options, focusing on wiredTiger as the default storage engine and repair commands. Understand directoryperdb, the fork option, and that ssl, sharding, and replica sets are covered later.
Learn to run MongoDB as a background service with fork on macOS and Linux, including a log file, and manage the Windows service with net start and net stop.
Learn to save MongoDB settings in a config file, create and edit it, and start the server using the config path with --config or -F for a reusable blueprint.
Explore the Mongo Shell options, connect to servers with host and port, and use help, admin commands, and database or collection commands like show dbs, show collections, and db.runCommand.
Explore MongoDB Compass, a graphical user interface for managing your data. Insert, update, delete, and view data, and open a database server with multiple databases.
download and install mongodb compass, connect to a local mongodb server, create a database and collection, insert documents with a nested point object, and explore data with compass.
Explore the create step of CRUD in MongoDB by examining insert methods, configuring them, and learning how to import existing data into the database.
Explore how to create documents in MongoDB using insertOne and insertMany, with automatic id generation, and compare with the older insert method, plus introducing the Mongo import tool.
Learn how to insert documents with insertOne and insertMany in a MongoDB collection, including how IDs are generated and returned, and why insert is less preferred for multi-doc writes.
Explore MongoDB insert methods, including insertMany with custom _id, and learn how ordered and unordered inserts affect write behavior and errors.
Discover how WriteConcern governs write acknowledgments for insertOne and insertMany, including W, journal (J), and W timeout, balancing performance and durability.
Experiment with writeConcern by inserting documents with insertOne and insertMany to observe acknowledgement differences with W:1 and W:0. Understand the impact of journaling and wtimeout on write durability and performance.
Demonstrates atomicity of write operations in MongoDB, including insertOne() with document-level rollback and the per-document nature of bulk inserts like insertMany().
Import data from a json file with mongo import into a movie data database's movies collection, using json array and drop to refresh.
Use insert one and insert many to add documents, since the legacy insert offers no created-id feedback, and choose ordered or unordered inserts to control error handling.
Learn how to read data from your database using filters, find, and projection operators, with cursor concepts to transform results. Practice with the Movies dataset and mongoimport.
Explore methods, filters, and operators in MongoDB, including find, insert, and delete on collections, with filters using field-value pairs and operators like $gt for range queries.
Understand read-related operators, including query operators like $gt and projection operators that shape returned data without changing it. Preview update operators and aggregation pipelines for data transforms.
Explore MongoDB query selectors—comparison, logical, element, evaluation, array, and comments—and geospatial selectors for location data, plus projection operators like $elemMatch and $slice; $meta is deferred to a later module.
Understand how findOne() and find() retrieve documents from a MongoDB collection, using filters to return the first matching document or all documents, with cursor behavior and pretty output.
Master MongoDB comparison operators, such as $eq, $ne, $gt, $gte, and $lte, to filter documents by conditions like runtime. Learn through practical queries and consult the official docs for coverage.
Learn to query embedded fields and arrays in MongoDB, using dot notation to reach nested fields like rating.average and the genres array, with operators for equality and greater-than.
Explore how MongoDB's $in and $nin operators filter documents by matching or excluding discrete values, using runtime examples like 30, 42, and 60 minutes.
Learn how to use MongoDB logical operators, especially $or and $nor, to filter documents by rating lower than 5 or greater than 9.3, combine conditions, and count results with count().
Explore how the MongoDB $and operator combines conditions like rating.average > 9 and genre drama, and learn why explicit and is used for same-field queries and driver compatibility.
Explore how the $not operator in MongoDB inverts a query to find items whose runtime is not 60 minutes, using $not with $equal to express not equal.
Explore element operators in MongoDB, focusing on $exists and $type, and learn to query for field existence and non-null values using practical examples with age and other fields.
Use the type operator to filter documents by data type, such as phone numbers stored as strings or numbers, and specify single or multiple types like string or doubles.
Explore evaluation operators with regex, learn how to use $regex to search text in summaries, and compare full equality versus pattern matching, noting text index and indexing module for performance.
Demonstrates using the $expr expression operator to compare fields within a document, filtering where volume exceeds target, and handling complex conditions with $cond and subtract.
Explore deeper array querying in MongoDB using dot notation to match embedded documents within arrays, such as hobbies.title equal to sports, and apply operators like greater than.
Explore how to use MongoDB's array query selectors, especially $size, to retrieve documents with an exact number of array elements, illustrated with a hobbies example.
Explore how to use the $all operator to find movies whose genre array contains thriller and action, regardless of order, in the box office moviestarts collection.
Learn how to use the $elemMatch operator in MongoDB to match a single embedded document in an array, ensuring both title and frequency criteria apply to the same element.
Explore how MongoDB cursors optimize queries by returning a pointer that fetches results in batches, enabling pagination and efficient data loading with 10-item chunks.
Explore MongoDB cursors by using find to create a cursor, count to gauge results, and next or for each to traverse documents, highlighting server side filtering for efficiency.
Sort cursor results by rating or embedded fields in MongoDB queries. Learn multi-criteria sorting with ascending and descending orders, and why sort applies to cursors but not findOne.
Use skip and limit on a MongoDB cursor to paginate results, showing how to skip 10, limit to 10 per page, and how sort order affects the retrieved documents.
Learn how projection in MongoDB shapes results by returning only selected fields like name, genres, runtime, and rating, using embedded data such as rating.average and schedule.time.
Explore how to query array data and project results in MongoDB by matching genres, using the $ projection to return the first element, and applying elemMatch for selective array values.
Explore how to use the slice operator in MongoDB projections to limit and shape array results, employing $slice, elemMatch, and array-form syntax.
Master updating documents in MongoDB using update one and update many, including setting fields, incrementing numbers, and modifying arrays by adding or removing elements.
Learn to update MongoDB documents using updateOne and updateMany with the $set operator, identifying targets by filters and safely adding or overriding fields like hobbies and isSporty.
learn how to update multiple fields with $set in MongoDB using updateOne, adding age and phone, and see that $set can modify or add fields, arrays, and embedded documents.
Learn to increment and decrement age with MongoDB’s $inc, optionally combining with $set for updates, and avoid conflicts when updating the same field.
Learn to use MongoDB min, max, and mul with updateOne to conditionally update fields. See min lower a value, max raise it, and mul multiply.
Use the unset operator to remove the phone field from sporty users via update many, ensuring the field is absent rather than null.
Rename fields in MongoDB by using updateMany with an empty filter and the $rename operator to change age to totalAge across documents; fields that do not exist are not renamed.
Use upsert in MongoDB updateOne or updateMany to insert a document when no match exists. The example sets age, hobbies, and isSporty, and shows name may populate from the filter.
Explore updating a specific matched array element in MongoDB with elemMatch and hobbies.$, targeting sports with frequency >=3 and adding a highFrequency flag.
Learn how to update all array elements in MongoDB using updateMany and the $[] placeholder, applying $set and $inc to embedded documents within the hobbies array.
Learn to locate documents with hobbies having a frequency greater than 2, then update matching array elements using updateMany and arrayFilters to set a nested goodFrequency flag.
Add elements to MongoDB arrays with $push and $each, preserve existing items, and use $sort (and optional $slice) to keep a sorted, bounded hobbies list.
Learn to remove elements from arrays in MongoDB using $pull with conditional criteria and $pop to remove the first or last element, as shown with Maria and Chris.
Understand how addToSet ensures unique values in an array by contrasting it with push, using the hiking hobby example to show that duplicates are not added.
Review updateOne() and updateMany() using a filter and update operators like $set and $inc. Note replacing documents with update or replaceOne(), and array updates using $push, $pop, arrayFilters, and upsert.
Learn how to delete documents and remove entire collections or databases, completing the CRUD cycle after creating, reading, and updating.
Use deleteOne to remove a single document by a filter, such as name equals Chris. Then use deleteMany to remove all matching documents, including those missing an age field.
Learn to delete all documents using delete many with an empty filter, and decide when to drop a collection or the database in the shell versus app queries.
Learn how indexes speed up MongoDB queries, when they may slow down operations, and how to choose and optimize index types to match your query patterns.
Explore how MongoDB indexes speed up find, update, and delete queries by converting collection scans into efficient index scans, using ordered value lists and pointers, while balancing insert costs.
Explore how to create and evaluate MongoDB indexes, use explain plans, and compare full collection scans with index scans to boost queries on embedded fields like dob.age.
Explore index restrictions in MongoDB and see how age-based queries behave with and without an index. Learn when full collection scans outperform indexing.
Create and leverage compound indexes to speed queries on multiple fields, such as age and gender, using left-to-right order; understand index scan vs collection scan and leftmost field effects.
Leverage indexes to sort queries by their index order, enabling index scans for age and gender and avoiding in-memory sorts that exceed 32 MB on large collections.
Inspect and verify collection indexes using getIndexes(), recognizing the default _id index MongoDB maintains automatically. Leverage this index for filtering or sorting by _id and identify additional user-created indexes.
Configure unique indexes in MongoDB by creating an ascending index on email with unique: true to prevent duplicates and enable faster lookups.
Understand partial indexes in MongoDB by using a partial filter expression on age (and optionally gender) to store only regularly queried values, and see index scans versus collection scans.
Learn how to use MongoDB's time to live index with expireAfterSeconds on a date field to delete self-destructing data, such as sessions, while noting it works on single-field date indexes.
Diagnose query efficiency using explain, executionStats, and allPlansExecution to compare index scans with collection scans. Evaluate time, keys examined, and documents returned, and understand when a covered query avoids examination.
Create a collection and index on name, then use executionStats to show an index scan. Reach a covered query by projecting only indexed field, such as name, with compound indexes.
Learn how MongoDB selects and rejects query plans using compound and single-field indexes, and how winning plans are cached and rebuilt with explain allPlansExecution.
Explore multi-key indexes in MongoDB, indexing arrays like hobbies and embedded documents like addresses, and learn they can't be combined as multiple multi-key fields in a single compound index.
Learn how text indexes turn the description field into keyword arrays, remove stop words, and stem words, enabling fast keyword and phrase searches with $text in MongoDB.
Learn how text indexes score results using the text score meta field and sort results by that score in MongoDB's text searches.
Create a single combined text index for title and description in MongoDB, acknowledging that only one text index per collection exists.
Explore how text indexes search for words and exclude terms with a minus operator. Apply the example by searching awesome minus t-shirt to yield only the book.
Set up and optimize MongoDB text indexes by creating combined title and description fields, configuring default language, applying language-specific stop words, and using weights to influence search scores.
Explore adding indexes in foreground and background, compare collection locking and accessibility, and observe performance with a million documents and an age index.
Master how indexes speed up queries and sorting in MongoDB, including single-field, compound, multi-key, and text indexes, while balancing write overhead and strategic index design.
Join this bestselling MongoDB course to learn all about this extremely popular database and query language from the ground up, in great detail and with many practical examples!
-
MongoDB is one of the most important NoSQL databases you can work with. It's extremely popular and MongoDB developers are in high demand!
No matter if you're building web applications, mobile applications or any other kind of application or if you're a data scientist - you'll need to work with data. Storing data, querying it efficiently and minimizing complexities whilst optimizing performance are crucial tasks.
MongoDB makes working with data simple - it's built on a philosophy that prioritizes performance and efficiency.
In this course, you learn all about MongoDB from scratch. No prior MongoDB or database experience is required!
In detail, you'll learn:
How to install and use MongoDB locally and in the cloud (MongoDB Atlas)
How to perform CRUD (Create, Read, Update, Delete) operations on MongoDB databases
How to filter for data efficiently
How to work with both the Mongo Shell and drivers (e.g. Node.js driver)
How to increase performance by using indexes (and how to use the right indexes!)
How to use the amazing "Aggregation Framework" that's built into MongoDB
What replica sets and sharding are
How to use MongoDB Atlas - the cloud solution offered by MongoDB
How to use the serverless platform (Stitch) offered by MongoDB
And much more!
This course is a hands-on course - you'll learn by writing code/ commands. We'll work on a wide variety of example data and use-cases and by the end of the course, you'll have all the knowledge you need to work with MongoDB in your next project!
This course is for you, no matter which programming language you plan on using, you'll learn a uniform way of interacting with MongoDB that can be easily applied to any language.
This course is for you:
if you're brand-new to MongoDB and databases in general
if you got some basic database or even MongoDB experience - in this course, there are different entry points you can choose from!
if you are a web or mobile app (or desktop app) developer who considers using MongoDB
if you're working in a team that considers using MongoDB (or already does use it)
if you are primarily using SQL-based databases so far and you want to explore the most popular NoSQL alternative
This course is NOT for you:
if you're looking for a guide on administrating MongoDB servers => This course focuses on the commands/ queries you write, it's NOT an administration course. I will show (in detail) how to deploy a ready-to-use cloud MongoDB solution that follows best practices though.