gorm-settings

Community

Pass contextual data into GORM hooks

Authorliurida
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Provides a scoped, operation-level mechanism to pass metadata such as audit user IDs, tenant identifiers, or migration options into GORM operations and hooks so you do not rely on global state or ad-hoc context passing.

Core Features & Use Cases

  • Set and Get values that propagate into all hooks, including nested association hooks, enabling audit trails and conditional hook behavior.
  • InstanceSet and InstanceGet for statement-scoped values that do not propagate to association hooks, useful for per-model transformations or temporary values.
  • Set table options during migrations to configure database engine or table comments for MySQL/MariaDB.
  • Common uses include audit logging, tenant isolation, skipping or toggling hook logic, and passing migration configuration.

Quick Start

Set an audit_user using db.Set before creating a model so the BeforeCreate hook can read and record the audit_user.

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-settings
Download link: https://github.com/liurida/gorm-development-skill/archive/main.zip#gorm-settings

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.