Aggregation Operations in TypeORM (Sum, Avg, Min, Max, Count)

September 4, 2022 Pennywise

This short and straightforward article shows you how to perform aggregation operations in TypeORM. We’ll use a query builder and aggregate functions to calculate the following: Sum: The sum of the values Avg: The average value…

TypeORM: Select the Most Recent Record (2 Examples)

September 4, 2022 Pennywise

This short article walks you through 2 examples of selecting the latest record from a table using TypeORM. The first example uses the findOne() method, while the second one uses a query builder. Using the findOne()…

TypeORM: Using LIKE Operator (2 Examples)

September 4, 2022 Snowball

In TypeORM, the Like operator (with the percent sign %) is used to search for a specified pattern in a column. This concise article walks you through 2 examples of selecting data with the Like operator…

TypeORM Upsert: Update If Exists, Create If Not Exists

September 20, 2022 Snowball

Upsert (this term is combined from two words: update and insert) is a database operation that updates a record it already exists in a table. Otherwise, insert a new row if that record doesn’t exist. This…

TypeORM: Check Whether a Row Exists or Not

September 1, 2022 Snowball

The 2 examples below demonstrate how to check if a record exists or not by using TypeORM findOne() method and query builder, respectively. Using the findOne() method Suppose we need to find a product named KatherineCode.com,…

TypeORM: Find Rows Where Column Value is IN an Array

August 31, 2022 A Goodman

This short and straight-to-the-point article shows you 2 different ways to use the WHERE IN query in TypeORM (in case you want to search for rows whose column values are an element of a given array)….

How to Store JSON Object with TypeORM

August 31, 2022 A Goodman

If you want to store some kind of flexible data with TypeORM, you can save them as JSON. You can specify the column type as simple-json. This helps you store and load Javascript objects with ease….

TypeORM: Add Columns with Array Data Type

August 31, 2022 A Goodman

When using TypeORM, it’s possible to define columns with the array data type. If you want to add a column that stores arrays of numbers, you can define it like so: In case you need a…

Pagination in TypeORM (Find Options & QueryBuilder)

May 20, 2022 Pennywise

This short and straight-to-the-point article shows you how to paginate data in TypeORM. Using Find(), FindAndCount() methods If you use a find method, you can implement pagination with the skip and take options: skip: offset from…

TypeORM: Entity with Decimal Data Type

May 20, 2022 Pennywise

In TypeORM, you can add a column with decimal data type like this: Where: precision: The number of digits in the decimal scale: The number of digits to the right of the decimal point Full example:…

TypeORM: Selecting Rows Between 2 Dates

May 3, 2022 A Goodman

The examples below show you how to select records between two given dates in TypeORM. The first one uses the find() function and the second uses query builder. Here’s the user entity that will have a…

TypeORM: Selecting Rows with Null Values

May 2, 2022 A Goodman

This succinct article is for people working with TypeORM who want to select records containing Null values. We’ll examine two examples. The first one uses the find() method, and the second uses Query Builder. Here’s the…

1 2 3 4 5