Cascade Delete in TypeORM

September 27, 2022 Snowball

When working with a database, the cascade delete feature ensures that deleting a parent record will also remove the child records. For instance, we have a table that stores information about users and another table that…

Node.js + Express + TypeScript: req.query type

September 14, 2022 Snowball

When working with Node and Express.js, there might be cases where you need to access req.query, an object that contains the property for each query string parameter in the route. For example, given a route like…

Node.js Error: listen EADDRINUSE: Address already in use

September 14, 2022 A Goodman

This quick article shows you how to solve a common error you might confront when working with Node.js. The Problem When developing a Node.js application (with Express.js), I sometimes fall into the following problem: Full error…

Nodemon: Automatically Restart a Node.js App on Crash

September 13, 2022 Guest Contributor

A large number of developers use Nodemon during the development and testing of Node.js apps. When your code file changes, Nodemon will automatically restart the program. However, when the app crashes, it will stop: This is…

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…

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

Node.js: 2 Ways to Delete All Files in a Folder

May 11, 2022 Napoleon

There might be cases where you want to empty an entire folder in Node.js. This article shows you a couple of different ways to do so. The first approach uses self-written code while the second one…

Node.js: Listing Files in a Folder

May 8, 2022 A Goodman

In Node.js, you can asynchronously list all files in a certain directory by using fs.promises. Example I have a Node.js project with the file structure as follows: Here’s the code in index.js: The output I get…

1 2 3 6