xiaohongshu
xiaohongshu
creating-gorm-entity
Creates GORM entity structs for go-kratos microservices with BaseModel embedding, proper field tags, relationships (one-to-one, one-to-many), indexing strategies, and soft delete support. Use when defining database schema, creating new entities, setting up table relationships, or configuring data...
Full skill instructions
Generate GORM entity structs that follow the project's Clean Architecture patterns, with proper field tags, relationships, indexing strategies, and soft delete support.
All entities MUST embed BaseModel which provides:
ID uint64 - Primary key with auto-incrementCreatedAt time.Time - Automatic timestampUpdatedAt time.Time - Automatic timestampDeletedAt gorm.DeletedAt - Soft delete support with indextype BaseModel struct {
ID uint64 `gorm:"primaryKey;autoIncrement"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
Fields MUST follow this exact order:
Example:
type Symbol struct {
BaseModel // 1. Base embedding
ProjectID uint64 `gorm:"..." // 2. Foreign key
UID string `gorm:"..." // 3. Required fields
Label string `gorm:"..."
ClassName string `gorm:"..."
ComponentTarget string `gorm:"..."
Version uint32 `gorm:"..."
SymbolData *SymbolData `gorm:"..." // 4. Relationship
}
Tags MUST follow this pattern: `gorm:"constraint1;constraint2;..." json:"field_name"`
Common constraints:
Critical indexing patterns:
// Composite unique index (project_id + uid)
ProjectID uint64 \`gorm:"not null;uniqueIndex:idx_project_uid,priority:1" json:"project_id"\`
UID string \`gorm:"not null;size:255;uniqueIndex:idx_project_uid,priority:2" json:"uid"\`
// Multiple indexes on same field
ProjectID uint64 \`gorm:"not null;uniqueIndex:idx_project_uid,priority:1;index:idx_project_id,priority:1;index:idx_symbols_project_deleted_at,priority:1" json:"project_id"\`
One-to-One with Cascade Delete:
type Symbol struct {
BaseModel
// ... other fields ...
SymbolData *SymbolData \`gorm:"foreignKey:SymbolID;references:ID;constraint:OnDelete:CASCADE" json:"symbol_data,omitempty"\`
}
type SymbolData struct {
BaseModel
SymbolID uint64 \`gorm:"not null;uniqueIndex" json:"symbol_id"\`
Data *[]byte \`gorm:"not null;type:longblob" json:"data"\`
}
MUST provide explicit table name method:
func (Symbol) TableName() string {
return "symbols" // plural, snake_case
}
When creating a GORM entity, verify:
❌ DON'T:
✅ DO:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience