Tag: mongodb

Test Password Strength and Password History with TypeScript and MongoDB

June 19, 2026 Nic Raboy

Just about every application you build is going to need some form of user authentication, and the moment you have user accounts, you have passwords to manage. Storing them safely is only part of the job. You also need to make sure those passwords are strong enough to be worth protecting in the first place, and in many cases, you need to make sure the same password isn't recycled every time it’s rotated.

Password reuse is a bigger deal than it sounds. Compliance frameworks frequently require that the last several passwords cannot be used again, and even outside of compliance, it is good hygiene. If a password leaks today and a user just rotates back to it six months from now, your rotation policy did not actually protect anyone.

MongoDB happens to be a really good fit for this kind of feature. A user document can store the current password hash at the root of the document, along with a growing array of previous hashes, all in the same record. There is no separate join table to set up and no migration to run when a user changes their password for the tenth time.

In this tutorial, we'll see how to build a small TypeScript API using Express Framework, Zod, and the MongoDB Node.js driver. This application registers users with strong password rules, authenticates them, and rejects any password change that has been seen before.

Read More

How to Install MongoDB on Ubuntu: A Step-by-Step Guide for Beginners

June 6, 2026 Nic Raboy

So you're ready to dabble with MongoDB on Linux and you've chosen Ubuntu as the variant you want to work with. Fantastic choice because you're in for a fairly easy experience that will get you up and running with MongoDB in no time!

In this tutorial, we'll explore installing MongoDB through the Ubuntu Package Manager and do some minor quality of life improvements that will better secure your installation from the rest of the world. While we'll be exploring the native installation experience, if you'd prefer to use Docker on Ubuntu for working with MongoDB, check out my previous tutorial, Running MongoDB in Docker - A Complete Guide with Examples.

Read More

Running MongoDB in Docker - A Complete Guide with Examples

May 29, 2026 Nic Raboy

So you're looking to self-host MongoDB or start dabbling with it in a local setting? There are a few options to get started if you don't want to jump directly into MongoDB Atlas, one of those options being containers with Docker. Making use of Docker is a solid choice when managing your MongoDB instance because it doesn't take more than a minute to do and it is easy to maintain or move between host computers.

In this article, we're going to see a few approaches toward deploying MongoDB with Docker and explore a few tips and tricks along the way.

Read More

How to Design Nested Documents for a Blogging App

May 22, 2026 Nic Raboy

So you want to build your own content management system (CMS), also sometimes known as a blog? This is a classic example when learning how to use a database, whether it be a relational database management system (RDBMS) or a NoSQL database, because it explores a potentially large amount of data as well as relationships in that data. The example of a blogging app also translates well for other data modeling needs.

In this article, we're going to explore some do's and don'ts when it comes to designing your NoSQL documents in MongoDB. However, we won't actually be developing a blogging app, only looking at things from a data perspective.

Read More

MongoDB and GraphQL: A Perfect Match

May 15, 2026 Nic Raboy

GraphQL is a powerful and efficient way to build APIs. The client queries the API, similarly to how they would a database, and that API returns only the data that they've requested, often reducing the response payload and improving response times. Low response times are critical in the modern world.

When the GraphQL API is paired with MongoDB, you're not only getting those fast response times, but you're also getting a data format that is consistent from start to finish.

Imagine this: Your client is executing a GraphQL query and that query looks similar to JSON. When the data reaches your application—which, let's say, is TypeScript in this example—you're now working with a data format that is similar to JSON in your application. Taking it a step further, when working with MongoDB, the data you send to and from MongoDB will also be similar to JSON. So what you're getting is that consistent data experience on top of performance. No need to worry too much about manipulating and formatting your data, and instead you get to focus on the user experience of your application, not the database and tooling.

In this tutorial, we're going to see just how easy it is to use MongoDB in your GraphQL API, this time built with TypeScript.

Read More

Building a REST API With Express Framework and MongoDB

May 8, 2026 Nic Raboy

Almost every modern web application will need a REST API for the frontend to communicate with, and in almost every scenario, that frontend is going to expect to work with JSON data. As a result, the best development experience will come from a stack that will allow you to use JSON throughout, with no transformations that lead to overly complex code.

Take MongoDB, Express Framework, and Node.js as an example.

Node.js and Express Framework handle your application logic, receiving requests from clients, and sending responses back to them. MongoDB is the database that sits between those requests and responses. In this example, the client can send JSON to the application and the application can send the JSON to the database. The database will respond with JSON and that JSON will be sent back to the client. This works well because MongoDB is a document database that works with BSON, a JSON-like data format.

In this tutorial, we'll see how to create an elegant REST API using MongoDB and Express Framework.

Read More

Using Dot Notation to Query Nested Fields in MongoDB

April 28, 2026 Nic Raboy

If you're just starting to dabble with MongoDB, you've probably come to a point where your documents are looking a little complex. These documents might have gone from flat, relational-looking pieces of data to something with nested objects, nested arrays, and maybe even four or five more levels of nesting. So how do you query this data when it is a few layers deep?

In this short tutorial, we're going to look at dot notation within MongoDB and see how we can very quickly and easily filter our documents based on data that contains certain values in the nested fields.

Read More