TypeORM: AND & OR operators

Updated: April 26, 2022 By: 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

Updated: April 22, 2022 By: Napoleon

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

Updated: April 23, 2022 By: 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

Updated: April 23, 2022 By: Napoleon

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)

Updated: March 19, 2022 By: 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

Updated: February 25, 2022 By: 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

Updated: February 7, 2022 By: 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

Updated: August 20, 2022 By: 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

Updated: February 6, 2022 By: 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

Updated: February 4, 2022 By: 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)….

2 Ways to Set Default Time Zone in Node.js

Updated: February 4, 2022 By: Pennywise

This short article walks you through 2 different ways to set the default time zone in Node.js. The first approach is to modify the TZ environment variable and the second one is to make use of…

Node.js: How to Compress a File using Gzip format

Updated: November 29, 2021 By: A Goodman

In Node.js, you can compress a file using the Gzip format by using streams. We can get the job done with just a few lines of code and there is no need to install any third-party…

1 2 3 4 6