Show Menu
Cheatography

TypeORM Cheat Sheet (DRAFT) by

Documenting features of TypeORM as I learn it

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Common CLI

typeorm
migration:
generate -n PostRe­fac­toring
typeorm
migration:
run
typeorm
migration:
revert

PG Types

 

Decorators

@Entity
@Column
@AfterLoad
@Index
@ViewE­ntity
@Prima­ryC­olumn
@Befor­eInsert
@Unique
------
@Prima­ryG­ene­rat­edC­olumn
@After­Insert
@Check
@OneToOne
@Objec­tId­Column
@Befor­eUpdate
@Exclusion
@ManyToOne
@Creat­eDa­teC­olumn
@After­Update
@Trans­action,
@OneToMany
@Updat­eDa­teC­olumn
@Befor­eRemove
@Trans­act­ion­Manager
@ManyT­oMany
@Versi­onC­olumn
@After­Remove
@Trans­act­ion­Rep­ository
@JoinC­olumn
@Generated
@Event­Sub­scriber
@Entit­yRe­pos­itory
@JoinTable
@Relat­ionId
 

API Migration Template

import {MigrationInterface, QueryRunner, Table } from "typeorm";

export class ModelnameRefactoringTIMESTAMP implements MigrationInterface {

    async up(queryRunner: QueryRunner): Promise<any> {
        // TypeORM API up commands go here for creating/updating
    }

    async down(queryRunner: QueryRunner): Promise<any> {
        // TypeORM API down commands go here for destroying/removing
    }

}