By default, when you print out something by using console.log() in Node.js, the output is usually white if your terminal has a dark background color or black if your terminal has a light background color. If you print a few short messages......
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......
In TypeORM, you can add a column with decimal data type like this: @Column({type: "decimal", precision: 10, scale: 2, default: 0}) price: number; Where: precision: The number of digits in the decimalscale: The number of......
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 makes use of a third-party package.......
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: . ├── files │ ├── a.jpg │ ├── b.png │ ├── c.xml │ ......
When performing CRUD operations with TypeORM, you can set timeout (maximum execution time) for a certain query like so: const productRepository = dataSource.getRepository(Product); const products = await productRepository ......
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......
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: %AppData%/npm-cache You can set......
The path module (one of the core modules of Node.js) gives us some methods to simply retrieve the name and extension of a file from a path or web URL: path.basename(path: string, extension?: string): Returns the file name with the......
The example below shows you how to automatically download an image served from Express server when clicking a link. 1. Navigate to the folder you want your project to lie in then run: npm init 2. Install express: npm i......
Node.js is a javascript runtime environment that helps you create high-performance apps. Because Node.js functions are non-blocking (commands execute concurrently or even in parallel, it can perform heavy tasks without incurring the cost......
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: // book.entity.ts import { Entity, PrimaryGeneratedColumn, ......