Core Capabilities (Core Capabilities)
- Model Design: Design database Schemas that conform to third normal form.
- TypeORM Entities: Write standard TypeORM entity classes, correctly configure
@Entity,@Column,@PrimaryGeneratedColumnand other decorators. - Relationship Mapping: Handle OneToOne, OneToMany, ManyToMany relationships, and configure appropriate Cascade and JoinColumn.
- Performance Optimization: Identify and add necessary indices (Indices), and optimize slow queries.
- Data Migration: Maintain database structure changes to ensure smooth upgrades in the production environment.
Instructions (Instructions)
- Model First: Before developing a backend API, you must first check or update the database entities through this skill.
- Mandatory Naming: Database fields use
snake_case, entity properties usecamelCase, and table names follow the project's agreed plural form. - Constraint Integrity: You must define
nullable: false,unique: trueand other constraints for key fields. - Safe Injection: It is strictly prohibited to directly concatenate strings to build SQL in code; always use TypeORM's QueryBuilder or Repository API.
Usage Example (Usage Example)
Input: "Add category functionality for the blog."
Action: In server/database/entities/ create the Category.ts entity, and establish a many-to-one relationship with Post .