gorm-scopes
CommunityBuild reusable, composable GORM queries
Authorliurida
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Reusable query conditions in GORM often get duplicated across handlers and models, making maintenance error-prone and inconsistent; this Skill consolidates query logic into composable scope functions to enforce consistent filtering, pagination, and routing across an application.
Core Features & Use Cases
- Reusable Scopes: Define functions that accept and return *gorm.DB to encapsulate common WHERE, JOIN, and ORDER conditions for reuse.
- Parameterized Scopes: Create closure-based scopes to accept dynamic values for statuses, amounts, tenant IDs, and date ranges.
- Pagination & Composition: Provide a single pagination pattern and combine multiple scopes to build complex queries without duplicating logic.
- Dynamic Table Routing & Multi-Tenancy: Swap table names or schemas at runtime for sharding or multi-org data separation.
- Update/Delete Safety: Apply row-level constraints as scopes to safely restrict update and delete operations by organization or tenant.
Quick Start
Create parameterized GORM scopes for pagination and tenant isolation and show example usage combining them with db.Scopes to query orders.
Dependency Matrix
Required Modules
None requiredComponents
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-scopes Download link: https://github.com/liurida/gorm-development-skill/archive/main.zip#gorm-scopes Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.