乐闻世界logo
搜索文章和话题

What is TypeORM and what are its core concepts?

2月17日 22:45

TypeORM is a TypeScript-based ORM framework that uses decorators to define the mapping between entity classes and database tables. Core concepts include:

  1. Entity: A class marked with @Entity() decorator, corresponding to a table in the database
  2. Column: Class properties marked with @Column() decorator, corresponding to columns in the table
  3. PrimaryGeneratedColumn: Auto-generated primary key column
  4. Repository: Data access layer for executing database operations
  5. DataSource: Core class that manages database connections and configuration

TypeORM supports both Active Record and Data Mapper patterns, allowing developers to choose the appropriate pattern based on project requirements. It also provides powerful query builders and relationship mapping features, making database operations more type-safe and convenient.

标签:TypeORM