Category: JavaScript

JavaScript NestJS SQL

API with NestJS #84. Implementing filtering using subqueries with raw SQL

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

In this series, we’ve often had to filter the records in our database. We can achieve that with a simple clause.

In this article, we go through different use cases of more advanced filtering. We achieve it by using the keyword with subqueries. EXISTS In some of the previous parts of this series, […]

JavaScript NestJS SQL

API with NestJS #83. Text search with tsvector and raw SQL

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

It is very common to implement a feature of searching through the contents of the database. In one of the previous articles, we learned how to implement it in a simple way using pattern matching. Today we take it a step further and learn about the data types explicitly designed for full-text search. Text Search […]

JavaScript NestJS SQL

API with NestJS #81. Soft deletes with raw SQL queries

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

Removing entities is a very common feature in a lot of web applications. The most straightforward way of achieving it is permanently deleting rows from the database. In this article, we implement soft deletes that only mark records as deleted. You can find the code from this article in this repository. The idea behind soft […]

JavaScript NestJS SQL

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

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