Category: NestJS

NestJS

API with NestJS #155. Offset and keyset pagination with the Drizzle ORM

This entry is part 155 of 168 in the API with NestJS

As our database grows, maintaining good performance becomes more important. Returning large amounts of data at once through our API can negatively affect efficiency. A common solution is to divide data into smaller chunks, presenting it to the user as infinite scrolling or multiple pages. In this article, we implement this approach using PostgreSQL and […]

NestJS SQL

API with NestJS #154. Many-to-many relationships with Drizzle ORM and PostgreSQL

This entry is part 154 of 168 in the API with NestJS

Creating relationships across tables is a crucial aspect of working with SQL databases. Previously, this series focused on using the Drizzle ORM to create simple relationships, such as one-to-one and many-to-one relationships. In this article, we learn about many-to-many relationships, which are slightly more complex. Introducing many-to-many relationships A many-to-many relationship is necessary when multiple […]

NestJS SQL

API with NestJS #153. SQL transactions with the Drizzle ORM

This entry is part 153 of 168 in the API with NestJS

Ensuring the integrity of the data is a fundamental responsibility of each developer. Fortunately, SQL databases give us the tools to ensure our database stays consistent and accurate. A crucial scenario to consider is when two SQL queries depend on each other. A typical example is transferring money between two bank accounts. Suppose we have […]

NestJS SQL

API with NestJS #152. SQL constraints with the Drizzle ORM

This entry is part 152 of 168 in the API with NestJS

When working with SQL databases, we can configure constraints to ensure our data does not get corrupted. In this article, we explore and implement different SQL constraints using PostgreSQL, NestJS, and the Drizzle ORM. Not-null constraint By default, SQL columns can hold nulls, representing an absence of value. We need the not-null constraint using the […]

NestJS SQL

API with NestJS #151. Implementing many-to-one relationships with Drizzle ORM

This entry is part 151 of 168 in the API with NestJS

Managing relationships between tables is a significant part of dealing with SQL databases. In this article, we continue learning to use Drizzle ORM with NestJS and implement many-to-one relationships. Check out this repository if you want to see the full code from this article. The many-to-one relationship With many-to-one relationships, a row from the first […]

NestJS SQL

API with NestJS #150. One-to-one relationships with the Drizzle ORM

This entry is part 150 of 168 in the API with NestJS

When building a database, the tables we set up often connect to each other. Managing these relationships is one of the crucial parts of working with databases. In the previous article, we learned how to use NestJS with Drizzle to set up a simple project with PostgreSQL. This time, we go further and write more […]

JavaScript NestJS

API with NestJS #148. Understanding the injection scopes

This entry is part 148 of 168 in the API with NestJS

When a NestJS application starts, it creates instances of various classes, such as controllers and services. By default, NestJS treats those classes as singletons, where a particular class has only one instance. NestJS then shares the single instance of each provider across the entire application’s lifetime, creating a singleton provider scope. If you want to […]