Cheatography
https://cheatography.com
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 PostRefactoring |
typeorm |
migration: |
run |
typeorm |
migration: |
revert |
Decorators
@Entity |
@Column |
@AfterLoad |
@Index |
@ViewEntity |
@PrimaryColumn |
@BeforeInsert |
@Unique |
------ |
@PrimaryGeneratedColumn |
@AfterInsert |
@Check |
@OneToOne |
@ObjectIdColumn |
@BeforeUpdate |
@Exclusion |
@ManyToOne |
@CreateDateColumn |
@AfterUpdate |
@Transaction, |
@OneToMany |
@UpdateDateColumn |
@BeforeRemove |
@TransactionManager |
@ManyToMany |
@VersionColumn |
@AfterRemove |
@TransactionRepository |
@JoinColumn |
@Generated |
@EventSubscriber |
@EntityRepository |
@JoinTable |
@RelationId |
|
|
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
}
}
|
|