Category: NestJS

NestJS SQL

API with NestJS #133. Introducing database normalization with PostgreSQL and Prisma

This entry is part 133 of 146 in the API with NestJS

Database normalization is a common topic in database design discussions. However, it’s usually explained using complicated terms, making it hard to understand. In this article, we’ll explain what normalization means and give examples using Prisma and PostgreSQL. The goal of database normalization is to enhance the accuracy and minimize the duplication of our data. We […]

NestJS SQL

API with NestJS #132. Handling date and time in PostgreSQL with Kysely

This entry is part 132 of 146 in the API with NestJS

Saving date and time in our database can be tricky, but it’s crucial to do it correctly. In this article, we address this problem using PostgreSQL and Kysely. We also explore time zones and how to handle them when designing our database. Dates in PostgreSQL We can determine how our database handles dates by examining […]

NestJS

API with NestJS #131. Unit tests with PostgreSQL and Kysely

This entry is part 131 of 146 in the API with NestJS

Creating tests is essential when trying to build a robust and dependable application. In this article, we clarify the concept of unit tests and demonstrate how to write them for our application that interacts with PostgreSQL and uses the Kysely library. Explaining unit tests A unit test ensures that a specific part of our code […]

NestJS

API with NestJS #130. Avoiding storing sensitive information in API logs

This entry is part 130 of 146 in the API with NestJS

In previous parts of this series, we’ve learned how to implement logging in our REST API. Logs play an important role in debugging and maintaining reliable services. However, they can pose security and privacy risks when misused. In this article, we will learn how to prevent sensitive information from being stored in our logs. Logging […]

NestJS SQL

API with NestJS #129. Implementing soft deletes with SQL and Kysely

This entry is part 129 of 146 in the API with NestJS

When working on our REST APIs, we usually focus on implementing the four fundamental operations: creating, reading, updating, and deleting (CRUD). Deleting entities is a common feature in many web applications. The simplest way to do it is by permanently deleting rows from the database. In this article, we use Kysely to explore the idea […]

NestJS SQL

API with NestJS #128. Managing JSON data with PostgreSQL and Kysely

This entry is part 128 of 146 in the API with NestJS

PostgreSQL is great for structured data and is known for its reliability in maintaining data organization and consistency. On the other hand, MongoDB stores data in flexible JSON-like documents, making it ideal for data with varying attributes and evolving requirements. Using SQL has a lot of advantages over MongoDB, but we might need some flexibility […]

NestJS SQL

API with NestJS #127. Arrays with PostgreSQL and Kysely

This entry is part 127 of 146 in the API with NestJS

PostgreSQL outshines various other SQL databases with its feature set. Unlike most SQL databases, PostgreSQL offers extensive support for array columns. Using them, we can store collections of values within a single column without creating separate tables. In this article, we explore the capabilities of arrays in PostgreSQL and implement examples using Kysely. Creating the […]