gorm-polymorphism

Community

Enable flexible polymorphic associations

Authorliurida
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Many applications need a child model to belong to different parent models, but traditional foreign keys require separate columns per parent type, causing schema bloat and inflexible queries. This skill provides a unified way to model such relationships in GORM.

Core Features & Use Cases

  • Unified Owner Columns: Stores both owner ID and owner type in a single table, reducing schema complexity.
  • Has‑One and Has‑Many Support: Works for singular and collection associations, e.g., a comment belonging to posts or videos.
  • Custom Column Names: Allows overriding default column names and type values for legacy schemas.
  • Eager Loading & Association Mode: Preload polymorphic data and manage relationships with GORM’s association API.
  • Practical Scenarios: Comment systems, taggable items, address books, and activity feeds where multiple entity types share a common child model.

Quick Start

Ask the skill to configure a polymorphic has‑many relationship between posts and comments.

Dependency Matrix

Required Modules

None required

Components

references

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: gorm-polymorphism
Download link: https://github.com/liurida/gorm-development-skill/archive/main.zip#gorm-polymorphism

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.