NestJS SQL

API with NestJS #181. Prepared statements in PostgreSQL with Drizzle ORM

This entry is part 181 of 181 in the API with NestJS

When we execute an SQL query, PostgreSQL follows a process that consists of multiple steps. First, it parses the SQL statement, checking for syntax errors. Next, it analyzes whether the tables and columns used in the query exist. Then, it plans the instructions necessary to achieve the desired result. Finally, it executes the instructions based on […]

NestJS

API with NestJS #180. Organizing Drizzle ORM schema with PostgreSQL

This entry is part 180 of 181 in the API with NestJS

As our application grows, it gets increasingly important to create a file structure that’s easy to maintain. Also, if we care about it from the start, it is easier to achieve. In this article, we learn how to organize the database schema when working with the Drizzle ORM and NestJS. Handling column names When working […]

NestJS

API with NestJS #179. Pattern matching search with Drizzle ORM and PostgreSQL

This entry is part 179 of 181 in the API with NestJS

Searching through text documents is a very common feature in many web applications. In this article, we learn how to implement it using pattern matching using the Drizzle ORM, PostgreSQL, and NestJS. Pattern matching with LIKE and ILIKE With pattern matching, we can determine if a given piece of text matches a particular pattern. To […]

NestJS

API with NestJS #177. Response serialization with the Drizzle ORM

This entry is part 177 of 181 in the API with NestJS

When fetching data from the database, we often don’t want to present it to the user in its raw form. To prevent that, we need to serialize the response in NestJS before sending it. The most popular way to achieve that in NestJS is using the library. In this article, we explain how to […]

NestJS SQL

API with NestJS #176. Database migrations with the Drizzle ORM

This entry is part 176 of 181 in the API with NestJS

Relational databases are known for their strict data structures. Every table requires a defined schema, including columns, indexes, and relationships. Despite careful planning during database design, application requirements often evolve. As a result, the database must adapt to keep up with these new needs. However, it’s crucial to ensure that no existing data is lost […]

NestJS SQL

API with NestJS #174. Multiple PostgreSQL schemas with Drizzle ORM

This entry is part 174 of 181 in the API with NestJS

PostgreSQL uses schemas as namespaces within the database to hold tables and other structures, such as indexes. In this article, we explain how to use them with the Drizzle ORM and how they can be beneficial. The public schema Out of the box, PostgreSQL creates a schema called for each new database. database-schema.ts

[…]

NestJS

API with NestJS #173. Storing money with Drizzle ORM and PostgreSQL

This entry is part 173 of 181 in the API with NestJS

We can’t cut corners on certain aspects of web development, and storing monetary values is one of them. In this article, we explore various data types in PostgreSQL we could use and discuss which ones to avoid. The drawbacks of floating point numbers When thinking about money, we often have to deal with fractions – […]

NestJS

API with NestJS #172. Database normalization with Drizzle ORM and PostgreSQL

This entry is part 172 of 181 in the API with NestJS

Database normalization is a key part of database design, but it’s often explained in complicated terms. In this article, we’ll break down the normalization rules and provide down-to-earth examples using Drizzle ORM and PostgreSQL. Database normalization aims to avoid unnecessarily duplicating our data and make it easier to manage. It does that through specific rules […]