MongoDB first impressions

Dev Ittycheria & MongoDB
1 follower
1 Video View·Apr 29, 2026
A deep dive into MongoDB.
The web dev world is obsessed with arguing about the best front-end framework or the
right architecture for your back-end API. But, in the grand scheme of things,
these debates don't actually matter. When you really think about it,
all web apps are just databases with a nice user interface painted on top.
So the data layer is what actually powers your app, keeps it consistent,
and makes everything else possible. If this layer is slow, unreliable or messy,
your other choices further up the stack are kind of irrelevant.
And, while SQL databases have been the default for decades,
the expectations and use cases of modern apps have shifted in recent years.
Today, developers are dealing with rapidly changing data models, unstructured content,
real-time updates, and distributed systems. And this is where MongoDB comes into play.
Mongo is the most popular document-based database by a wide margin, and it is built
specifically to handle the kind of data most modern applications actually work with.
Instead of forcing you into rigid schemas like traditional SQL databases,
MongoDB stores data in flexible JSON-like documents, which makes it much easier to
adapt to changing requirements without having to rewrite your whole back-end.
What's even more exciting is that it doesn't require a complex setup,
the query language feels natural if you already know JavaScript, and it's lightweight enough to
be a great fit not only for large-scale apps, but for small projects and prototypes as well.
So let's take a few minutes to look at what MongoDB actually is,
how its architecture stacks up against more rigid SQL solutions, what the developer experience
feels like, and review some practical tips to keep in mind if you decide to use it.
I also have to thank them for sponsoring this video.
Mongo was designed back in 2007 by a startup called TenGen out of pure necessity.
The startup was building a platform-as-a-service solution designed to compete with early cloud
platforms like the Google App Engine. But they hit a wall almost immediately
because the relational databases available at the time couldn't keep up with the flexibility
and performance demands of modern applications. So they built their own solution.
What started as just one component of their platform quickly became the main focus.
In 2009, they open-sourced it as MongoDB, and it quickly gained popularity,
especially among startups that needed to move fast and couldn't afford to wrestle
with rigid SQL schemas. By 2017, MongoDB went public.
Since then, the company has continued to grow, and today, Mongo ranks as the fifth
most popular database in the world, behind only long-established relational databases
backed by tech giants. MongoDB's success comes down to a few
core strengths and design decisions. First of all, it uses a document-based
structure that stores data in self-contained binary JSON files so you can represent complex,
nested data in a way that maps naturally to how it's used in your code.
This makes it easier to work with real-world data structures without having to flatten
everything into rigid rows and columns. On top of that, since documents are
self-contained, it's also more efficient to fetch exactly what you need in a single query
without the need for aggregation or joins. Second, and we'll actually look at some
practical examples soon, Mongo has a really friendly developer experience.
The syntax is familiar if you've written JavaScript, and the learning curve is shallow.
But you shouldn't be fooled by this apparent simplicity,
because Mongo can do much more than simple key-value lookups.
It supports powerful queries, secondary indexes, and an aggregation framework that lets you process
and transform data server-side. You can filter, group, sort, and reshape
documents without needing to pull everything into your app first.
What's more interesting, however, is Mongo's built-in support for horizontal scaling.
From the beginning, the database was designed to scale across multiple servers through sharding.
You can split large datasets across different nodes, making it easier to handle high traffic
and large volumes of data without relying on vertical scaling or expensive infrastructure.
But the good news is that you can avoid all the scaling headaches thanks to its
cloud-native fully-managed solution. MongoDB Atlas removes all the overhead
of running your own database server, and it lets you deploy databases across AWS,
Azure, or GCP with just a few clicks. Atlas handles provisioning, backups,
monitoring, scaling, and security updates, while including features like full-text search,
role-based access control, real-time performance monitoring, and serverless triggers.
But enough with the theory, let's look at some practical examples.
First, the chances are you are more familiar with relational databases,
so let's see how Mongo's architecture differs from what you're probably used to.
If you're coming from the world of relational databases,
you're used to thinking in terms of tables, rows, and columns.
You define a schema up front, lock everything in place, and then every row has to follow that exact
shape. If your app requirements change, you're either altering the schema or juggling migrations.
MongoDB is much simpler. Instead of tables, you have collections, and instead of rows,
you have documents. A collection can contain documents with different fields,
and Mongo doesn't enforce a schema by default. That means you can store data with different
shapes in the same collection, and the database won't complain.
So, in practice, we can start the Mongo shell, create a database,
and then define our first collection by simply inserting one document into it.
As I already said, Mongo doesn't enforce any schema, so we can use the insertMany command
to add more entries in our collection, each with different shapes and fields.
Sure, this is convenient, but it immediately triggers a common reaction.
This flexibility is just asking for trouble. And, to be fair, if you just throw random data
into your collections without any structure, you're going to regret it later.
Just because Mongo lets you store documents with different shapes,
it doesn't mean you should do it blindly. Flexibility is great, but it doesn't
replace discipline. You still need clear expectations for your data models,
and MongoDB offers the necessary tools needed whenever you want to enforce more structure.
This is the pattern across the board whenever you are working with Mongo.
It doesn't get in your way, but it doesn't leave you stranded either.
So, once we have inserted some documents in our collection,
we can test the other basic data operations. We can use find to read documents,
and this gives us a lot of flexibility, ranging from finding based on a condition,
to matching nested fields using regular expressions, or filtering by array contents.
You can also narrow down the fields you get as a result by adding a projection to your query.
You can update a single field, multiple fields, or even apply operators like increase,
push, pull, or unset, depending on what you're trying to do.
And, of course, deleting documents is straightforward as well.
But, whenever somebody is mentioning NoSQL databases,
we really need to address the elephant in the room.
If you're used to modeling your data in normalized tables, and joining them with SQL,
the idea of not having joins feels like a deal breaker.
And, if you've been building anything financial or critical,
the lack of transactions sounds like a non-starter.
Mongo wasn't originally built with joins in mind, because the document model encourages
embedding related data directly inside a single document.
The idea is simple. If two things are usually accessed together, store them together.
So, instead of having a separate users table and addresses table,
you just store the address right inside the user document.
But, that's not always practical. Sometimes you do need to reference other collections,
and that's where lookup comes into play.
This allows you to perform join-like operations inside MongoDB's aggregation pipeline,
and lets you reference documents from another collection,
to combine them into your result set, based on matching fields.
Multi-document ACID transactions are also fully supported.
You can update several documents across different collections in a single atomic operation,
even in sharded clusters.
From a developer perspective, using transactions is pretty familiar.
You start a session, perform your operations inside that session,
and either commit or abort a transaction, depending on how things go.
If one part fails, everything rolls back.
And, that's what makes MongoDB interesting.
You get the flexibility of an OSQL database,
without giving up the consistency and reliability developers expect from relational systems.
Please let me know in the comments if you are interested in seeing how Mongo pairs up
with a language like Go or Kotlin.
Don't forget to like the video, subscribe to the channel,
and, until next time, thank you for watching.
