Claude-skill-registry-data mikro-orm-entity
Use when creating or modifying MikroORM entity files in the `entities/` folder.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry-data
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry-data "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/mikro-orm-entity" ~/.claude/skills/majiayu000-claude-skill-registry-data-mikro-orm-entity && rm -rf "$T"
manifest:
data/mikro-orm-entity/SKILL.mdsource content
MikroORM Entity Guide
Use this skill when creating or modifying MikroORM entity files (
*.entity.ts).
Basic Entity Structure
import { Entity, PrimaryKey, Property, Unique } from '@mikro-orm/core'; import { uuidv7 } from 'uuidv7'; import { EntityEnum } from '../entity.enums'; @Entity() export class EntityName { @PrimaryKey({ type: 'uuid' }) id: string = uuidv7(); @Property() @Unique() uniqueField!: string; @Property({ length: 30, nullable: true }) optionalField?: string; @Property({ type: 'date', nullable: true }) dateField?: Date; @Property({ type: 'string', nullable: true }) enumField?: EntityEnum; @Property({ onCreate: () => new Date() }) createdAt?: Date; @Property({ onCreate: () => new Date(), onUpdate: () => new Date() }) updatedAt?: Date; }
Core Rules
1. Primary Key
- Use UUID v7: Use
package for time-ordered UUIDsuuidv7 - Assign default value directly in class field (
)= uuidv7()
2. Property Decorators
- Required fields: Use
(definite assignment assertion)! - Optional fields: Use
(optional) with?
optionnullable: true - String length limits: Use
optionlength - Date type: Explicitly specify
{ type: 'date' }
3. Enum Fields
- Use
@Property({ type: 'string' }) - Define enums in separate
file.enums.ts
4. Timestamps
: Auto-set on creationonCreate
: Auto-update on modificationonUpdate- Both fields declared as optional (
)?
5. Unique Constraints
- Place
decorator below@Unique()@Property()
Enum File Structure (*.enums.ts)
export enum EntityStatus { ACTIVE = 'ACTIVE', INACTIVE = 'INACTIVE', DELETED = 'DELETED', } export enum EntityType { TYPE_A = 'TYPE_A', TYPE_B = 'TYPE_B', }
- Values in uppercase SNAKE_CASE
- Keep key and value identical
File Naming Conventions
- Entity file:
{entity-name}.entity.ts - Enum file:
{module-name}.enums.ts - Folder structure:
src/{module}/entities/