Category: MongoDB

JavaScript MongoDB NestJS TypeScript

API with NestJS #48. Definining indexes with MongoDB and Mongoose

This entry is part 48 of 121 in the API with NestJS

The bigger our database is, the more demanding our queries become in terms of computing power. A common way of tackling this problem is by creating indexes. In this article, we explore this concept and create indexes with MongoDB and Mongoose. When performing a MongoDB query, the database must scan every document in a given […]

JavaScript MongoDB NestJS TypeScript

API with NestJS #47. Implementing pagination with MongoDB and Mongoose

This entry is part 47 of 121 in the API with NestJS

When our application grows, so does the database. At some point, we might return a lot of data from our endpoints. It might prove to be too much for our frontend application to process, for example. Therefore, we might need to paginate our records by returning just a portion of them. This article explores different ways […]

JavaScript MongoDB NestJS TypeScript

API with NestJS #46. Managing transactions with MongoDB and Mongoose

This entry is part 46 of 121 in the API with NestJS

While working with databases, keeping the integrity of the data is crucial. For example, imagine transferring money from one bank account to another. To do that, we need to perform two separate actions. First, we withdraw the amount from the first bank account. Then, we add the same amount to the second account. If the […]

JavaScript MongoDB NestJS TypeScript

API with NestJS #45. Virtual properties with MongoDB and Mongoose

This entry is part 45 of 121 in the API with NestJS

In this series, we’ve used Mongoose to define properties in our schemas and work with models for documents. We’ve also defined various relations between collections. With Mongoose, we can also take advantage of virtual properties that are not stored in MongoDB. To understand them, we first grasp the concept of getters and setters. You can find the code […]

JavaScript MongoDB NestJS

API with NestJS #43. Introduction to MongoDB

This entry is part 43 of 121 in the API with NestJS

So far, in this series, we’ve focused on working with SQL and the Postgres database. While PostgreSQL is an excellent choice, it is worth checking out the alternatives. In this article, we learn about how MongoDB works and how it differs from SQL databases. We also create a simple application with MongoDB and NestJS. You […]