TypeORM is a ORMapper for TypeScript.
🐞 Installation
yarn add typeorm |
🐝 Basic Usage for Active Record pattern
Model Definition
Active Record pattern is an approach to access your database within your models.
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from "typeorm"; |
Save/Delete/Fetch
This is a example of how to use the entity:
// example how to save AR entity |
If you want to know more details, please see Active Record vs Data Mapper.
😸 Fetch with related table
class Review { |
🎃 Transaction
Transactions are creating using Connection
:
import { getConnection } from "typeorm"; |
If you want to know more details, please see Transactions.
🎉 Relations
Please see the following links:
- https://github.com/typeorm/typeorm/blob/master/docs/relations-faq.md
- https://github.com/typeorm/typeorm/blob/master/docs/eager-and-lazy-relations.md
🖥 Recommended VPS Service
VULTR provides high performance cloud compute environment for you.
Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour).
In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!