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…

Javascript: Subtracting Days/Hours/Minutes from a Date

September 7, 2022 Snowball

There will be many cases where you need to subtract a number of days/hours/minutes/seconds from a given date object. The following examples will demonstrate how to do that in Javascript. In the first example, we’re just…

2 Ways to Format Currency in Javascript

September 7, 2022 Snowball

In Javascript, you can format currency strings in 2 different ways: Intl.NumberFormat() Number.toLocaleString() Both of these approaches work on all modern web browsers and Node.js No third-party libraries are required. Example of using Intl.NumberFormat: Output: Example…

How to Use Subqueries in TypeORM

September 7, 2022 Snowball

This article is about using subqueries with query builders in TypeORM. Let’s say we have an entity named Product: The code snippet below finds products with a higher than average price by using a subquery (that…

TypeORM: Get Raw SQL Query from QueryBuilder

September 7, 2022 Snowball

When communicating with databases through TypeORM, you can get raw SQL queries produced by query builders by using the getQuery() or getSql() methods (you can use them synchronously without the await keyword). Example: Output: If you…

TypeORM: How to Use Column Alias when Querying Data

September 7, 2022 Snowball

This succinct tutorial shows you how to use column aliases to assign temporary names to columns when selecting data with TypeORM. The point here is the AS keyword. Let’s study a couple of examples for more…

TypeORM: Selecting DISTINCT Values

September 5, 2022 Pennywise

In real life, it’s possible that a column contains many duplicate values. However, there might be occasions when you only want to get different (unique) values. If you’ve worked with MySQL or PostgreSQL, you are very…

TypeORM: Sort Results by a Relation Column

September 5, 2022 Pennywise

When using TypeORM to interact with databases, there might be occasions when you want to take records and sort them based on a relational field. There are 2 solutions for this: using find options and using…

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…

Pandas: Coerce a DataFrame into a Series

September 2, 2022 Napoleon

There might be occasions when you want to convert a Pandas data frame into a series. You can do so by using the squeeze() method. If your data frame has only a single column, you can…

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()…

1 2 3 4 85