Category: SQL

JavaScript NestJS SQL

API with NestJS #79. Implementing searching with pattern matching and raw SQL

This entry is part 79 of 92 in the API with NestJS

The possibility of searching through the contents of the database is a very common feature. There are great solutions built with that use case in mind, such as Elasticsearch. Even though that’s the case, PostgreSQL also has the functionality of matching a given string pattern. In this article, we explore what PostgreSQL offers and use […]

JavaScript NestJS SQL

API with NestJS #76. Working with transactions using raw SQL queries

This entry is part 76 of 92 in the API with NestJS

One of the challenges when working with databases is keeping the integrity of the data. In this article, we learn how to deal with it using transactions. A transaction can contain multiple different instructions. The crucial thing about a transaction is that it either runs entirely or doesn’t run at all. Let’s revisit the most common […]

JavaScript NestJS SQL

API with NestJS #75. Many-to-many relationships using raw SQL queries

This entry is part 75 of 92 in the API with NestJS

Designing relationships between tables is one of the crucial parts of working with databases. In this article, we look into a more complex relationship called many-to-many. You can find the code from this article in this repository. The many-to-many relationship A many-to-many relationship happens when many records in one table relate to many records in another […]

JavaScript NestJS SQL

API with NestJS #74. Designing many-to-one relationships using raw SQL queries

This entry is part 74 of 92 in the API with NestJS

Learning how to design and implement relationships between tables is a crucial skill for a backend developer. In this article, we continue working with raw SQL queries and learn about many-to-one relationships. You can find the code from this article in this repository. Understanding the many-to-one relationship When creating a many-to-one relationship, a row from […]

NestJS SQL

API with NestJS #69. Database migrations with TypeORM

This entry is part 69 of 92 in the API with NestJS

When working with relational databases, we define the structure of the data rather strictly. For example, we need to specify the format of every table along with fields, relations, indexes, and other structures. By doing that, we also tell the database how to validate the incoming data. It is crucial to think about the structure […]

NestJS SQL

API with NestJS #65. Implementing soft deletes using MikroORM and filters

This entry is part 65 of 92 in the API with NestJS

In this article, we look into the filters feature and implement soft deletes. With them, we can mark an entity as deleted without removing it from the database permanently. You can get the code from this article in this repository. Introducing MikroORM filters We can provide various filters when querying data using functions such as […]