Category: SQL

NestJS SQL

API with NestJS #123. SQL transactions with Kysely

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

The integrity of our data should be one of the primary concerns of web developers. Thankfully, SQL databases equip us with tools that we can use to ensure the consistency and accuracy of our data. You can see the complete code from this article in this repository. One of the critical situations to consider is […]

NestJS SQL

API with NestJS #122. Many-to-many relationships with Kysely and PostgreSQL

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

Implementing relationships across tables is a crucial aspect of working with SQL databases. So far, this series covers using Kysely to design simple relationships such as one-to-one and many-to-one. This article looks into many-to-many, which is a slightly more advanced relationship. Check out this repository if you want to see the full code from this […]

SQL

API with NestJS #121. Many-to-one relationships with PostgreSQL and Kysely

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

Designing relationships is one of the crucial aspects of working with SQL databases. In this article, we continue using Kysely with NestJS and implement many-to-one relationships. Check out this repository if you want to see the full code from this article. Introducing the many-to-one relationship When implementing the many-to-one relationship, a row from the first table […]

NestJS SQL

API with NestJS #119. Type-safe SQL queries with Kysely and PostgreSQL

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

Object-Relational Mapping (ORM) libraries such as Prisma and TypeORM can help us produce code faster by avoiding writing SQL queries. They have a smaller learning curve because we don’t need to learn a new language and dive deep into understanding how the database works. Unfortunately, ORM libraries often generate SQL queries that are far from […]

NestJS SQL

API with NestJS #115. Database migrations with Prisma

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

One of the characteristics of relational databases is a strict data structure. We need to specify the shape of every table with its fields, indexes, and relationships. Even if we design our database carefully, the requirements that our application must meet are changing. Because of that, our database needs to evolve as well. When restructuring […]

NestJS SQL

API with NestJS #111. Constraints with PostgreSQL and Prisma

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

One of the most important aspects of working with a database is ensuring the stored information is correct. One of the fundamental ways of doing that is by using the correct data types for the columns in our tables. Thanks to that, we can make sure that a particular column holds only numbers, for example. […]

NestJS SQL

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

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