JavaScript MongoDB NestJS TypeScript

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

This entry is part 48 of 51 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 51 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 #45. Virtual properties with MongoDB and Mongoose

This entry is part 45 of 51 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 51 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 […]

JavaScript SQL

Defining constraints with PostgreSQL and TypeORM

An important part of designing a database is controlling the data we store inside. The most fundamental way of doing that is defining the types for our columns. With that, we can make sure that a particular column holds only text, for example. In this article, we use constraints to have even more control of […]