TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript. Its goal is to always support the latest JavaScript features and provide additional features that help you to develop any kind of application that uses databases - from small applications with a few tables to large scale enterprise applications with multiple databases Official website: https://typeorm.io/#/
yarn typeorm migration:create -n Nome // create a migration
yarn typeorm migration:run // run all migrations
yarn typeorm migration:revert // revert migration
yarn typeorm schema:drop // delete all migrations
ps: on package script → ts-node-dev ./node_modules/typeorm/cli.js
ormconfig.json // TypeORM configurations
database: '',
user and password,
entities: [],
migrations: [ 'folder_name' ],
cli: { migrationDir: 'folder_name' }
<aside> 📌 ❯ Entity is the DB model ❯ Decorators: @function() → pass the class as a parameter ❯ bcryptjs: package to encrypt the password
</aside>
@Entity('transactions')
class Transaction {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
title: string;
@ManyToOne(() => Category)
@JoinColumn({ name: 'category_id' })
category: Category;
@CreateDateColumn()
created_at: Date;
@UpdateDateColumn()
updated_at: Date;
}