Category: NestJS

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 NestJS TypeScript

API with NestJS #42. Authenticating users with Google

This entry is part 42 of 51 in the API with NestJS

Authenticating users with emails and passwords is a valid and common approach. However, a convenient alternative is to shift this responsibility to a third party. In this article, we look into adding Google authentication to a NestJS project. We can achieve the above because Google uses the OAuth (Open Authorization) framework. With it, Google users […]