TypeORM: Counting Records in One-To-Many Relation

September 4, 2022 Pennywise

When communicating with the database through TypeORM, there will be many cases where you need to count records in a one-to-many relationship, such as: You want to list the users and the number of photos belonging…

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,…

Node.js: Turn a Relative Path into an Absolute Path

September 1, 2022 Snowball

In Node.js, you can convert a relative path to an absolute path simply by using the path module, like this: This is my output on macOS (if you’re using Windows, your result will be more or…

Javascript: Convert Relative URLs to Absolute URLs

September 1, 2022 Pennywise

In Javascript, you can easily convert a relative URL to an absolute URL like so: This works well regardless your relative URL starts with a slash (“/”) or not. Below is a concrete example: Output: Alternative…

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…

React: Using inline styles with the calc() function

August 24, 2022 A Goodman

This short and straightforward article shows you how to use the CSS calc() function when using inline styles in React. Overview The calc() function calculates the value for a property (addition, subtraction, multiplication, and division operations):…

1 2 3 4 5 81