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

May 11, 2022 The Plumber

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…

TypeORM: AND & OR operators

April 26, 2022 A Goodman

This concise, straight-to-the-point article gives a few quick examples of using AND and OR operators in TypeORM. No more rambling; let’s get our hands dirty by writing some code. Creating a sample entity In the coming…

TypeORM: How to store BIGINT correctly

April 22, 2022 The Plumber

If you’re using TypeORM to work with PostgreSQL or MySQL and want to save BIGINT (from -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)) to your database, you have to define your column as follows: The important thing here…

TypeORM: How to Limit Query Execution Time

April 23, 2022 Pennywise

When performing CRUD operations with TypeORM, you can set timeout (maximum execution time) for a certain query like so: If the query above takes more than 3000 milliseconds, it will be dropped to avoid crashing the…

TypeORM: 2 Ways to Exclude a Column from being Selected

April 23, 2022 The Plumber

When working with TypeORM, there might be cases where you want to exclude one or multiple columns (fields) from being selected. This succinct article will show you two different ways to do that. Make a column…

How to change NPM cache location (Windows & Mac)

March 19, 2022 A Goodman

This concise article shows you how to change the npm cache folder in Windows and macOS. Without any further ado, let’s get started. Windows The default npm cache folder in Windows is: You can set your…

TypeORM: Adding Fields with Nullable/Default Data

February 25, 2022 A Goodman

By default, every field (column) of a TypeORM entity is NOT NULL. You can make a specific field become nullable by setting the nullable option to true, like this: In case you want to add the…

Using ENUM Type in TypeORM

February 7, 2022 A Goodman

If you’re working with PostgreSQL or MySQL and making use of TypeORM in your code then you can add a column with the ENUM (enumerated) data type like so: This entity will create a table named…

TypeORM: Property ‘id’ has no initializer and is not definitely assigned in the constructor

February 6, 2022 A Goodman

When defining entities with TypeORM and TypeScript, you may encounter an annoying issue as follows: The warnings are present not only in the id field but also in all other fields in my classes entity: The…

TypeORM: Adding created_at and updated_at columns

February 6, 2022 A Goodman

In TypeORM, you can add a created_at column and a updated_at column by making use of the CreateDateColumn and UpdateDateColumn decorators, respectively. These columns will be automatically initialized and updated to the current date and time…

Node + TypeScript: Export Default Something based on Conditions

February 4, 2022 Pennywise

There might be times when you might want to export something based on one or multiple conditions (for example, you want to export configuration information like database, API keys, etc for development environment and production environment)….

1 2 3 5