Category: TypeScript

NestJS SQL

API with NestJS #110. Managing JSON data with PostgreSQL and Prisma

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

Relational databases such as PostgreSQL are great for storing structured data. This approach has many advantages, but it can lack flexibility. On the other hand, databases such as MongoDB that store JSON-like documents might give you more flexibility than you would like. Fortunately, PostgreSQL offers support for storing and querying loosely-structured JSON data. This article […]

NestJS SQL

API with NestJS #109. Arrays with PostgreSQL and Prisma

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

PostgreSQL stands out as a feature-reach solution among other relational databases. Most of the column types available in PostgreSQL allow storing a single value. However, PostgreSQL, unlike most SQL databases, enables us to define columns as arrays. With them, we can store collections of values within a single column, reducing the need to create separate […]

NestJS SQL

API with NestJS #108. Date and time with Prisma and PostgreSQL

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

Storing date and time in our database might be tricky, but it is essential to get it right. In this article, we tackle this issue using PostgreSQL and Prisma. We also learn the concept of timezones and how to deal with them when designing our database. How PostgreSQL interprets dates We can learn how our […]

NestJS SQL

API with NestJS #107. Offset and keyset pagination with Prisma

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

The bigger our database, the more we need to care about the performance. Returning too much data at once through our API might not be the best approach when it comes to performance. A common solution is to divide our data into chunks and present it to the user as infinite scrolling or multiple pages. […]

NestJS SQL

API with NestJS #106. Improving performance through indexes with Prisma

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

The bigger our database, the more we need to care about its performance. A common way of improving it is through indexes. Therefore, this article introduces the idea of indexes and implements them through Prisma. You can find the code from this article in this repository. Introduction to indexes In one of the recent articles, […]

NestJS SQL

API with NestJS #105. Implementing soft deletes with Prisma and middleware

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

When developing our REST APIs, we often focus on implementing the four fundamental operations: creating, reading, updating, and deleting (CRUD). The most basic approach to removing a record from our database is to delete it permanently. In this article, we explore the idea of soft deletes that allow us to keep the removed entities in the database. […]

NestJS

API with NestJS #104. Writing transactions with Prisma

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

As web developers, one of our primary concerns is keeping the integrity of our data. Fortunately, SQL databases come equipped with tools that allow us to ensure data accuracy and consistency. You can find the code from this article in this repository. One of the most fundamental examples of when things might go wrong is […]

NestJS

API with NestJS #103. Integration tests with Prisma

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

In the previous part of this series, we learned how to write unit tests in a NestJS project with Prisma. Unit tests help verify if individual components of our system work as expected on their own. However, while useful, they don’t guarantee that our API functions correctly as a whole. In this article, we deal […]

NestJS

API with NestJS #102. Writing unit tests with Prisma

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

Covering our NestJS application with unit tests can help us create a reliable product. In this article, we introduce the idea behind unit tests and implement them in an application working with Prisma. In this article, we continue the code developed in API with NestJS #33. Managing PostgreSQL relationships with Prisma Introducing unit tests A […]