GORM ORM

Provide Go code examples for GORM ORM database operations.

Updated Jan 22, 2026
One-click install
npx skills add https://github.com/ngxtm/skill-rule --skill gorm-orm-ngxtm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: GORM ORM
Source: https://github.com/ngxtm/skill-rule/tree/main/rules/golang/gorm-orm
Command: npx skills add https://github.com/ngxtm/skill-rule --skill gorm-orm-ngxtm

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive set of standards and examples for using the GORM ORM in Go, simplifying database operations, model definitions, and query patterns.

Core Features & Use Cases

  • Database Connection: Establish and configure database connections.
  • Model Definitions: Define Go structs with GORM tags for schema mapping and constraints.
  • CRUD Operations: Perform Create, Read, Update, and Delete operations efficiently.
  • Querying: Build complex queries with conditions, joins, and preloading.
  • Associations: Manage one-to-many, many-to-many, and other relationships.
  • Transactions & Hooks: Ensure data consistency and implement custom logic.
  • Migrations: Guidance on database schema evolution.

Quick Start

Use the GORM ORM skill to define a User model with basic fields and then perform a create operation.

Frequently Asked Questions about GORM ORM

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define Go structs with GORM tags for database schema mapping?

To define Go structs with GORM tags, you add struct tags to your model fields to specify schema mapping and constraints. This allows GORM to automatically handle database interactions and schema evolution based on your Go structs.

What is the best way to build complex queries with associations and preloading in GORM?

The best way to build complex queries in GORM is by using its built-in methods for conditions, joins, and preloading. This approach efficiently manages one-to-many and many-to-many relationships while fetching associated data.

How do I manage transactions and implement hooks in a Go application using GORM?

To manage transactions and implement hooks in GORM, you use its transaction management functions to ensure data consistency. Hooks allow you to trigger custom logic before or after specific database operations like CRUD actions.

Can I use GORM to perform CRUD operations and manage database migrations in Go?

Yes, you can use GORM to perform efficient CRUD operations and manage database migrations in Go. It provides comprehensive standards and examples for creating, reading, updating, and deleting records, alongside schema evolution guidance.