gorm-advanced-query

Build complex GORM database queries with subqueries, row locking, and scopes.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-advanced-query
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gorm-advanced-query
Source: https://github.com/liurida/gorm-development-skill/tree/main/advanced_query
Command: npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-advanced-query

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Manages complex data retrieval scenarios in Go applications using GORM, eliminating the need to write verbose raw SQL for subqueries, row locking, batch processing, and reusable query conditions.

Core Features & Use Cases

  • Smart field selection automatically selects only required columns when mapping to smaller structs.
  • Row locking provides FOR UPDATE and FOR SHARE locks with options like NOWAIT and SKIP LOCKED for safe concurrent updates.
  • Subqueries enable embedding queries within WHERE or FROM clauses without manual SQL string concatenation.
  • Group conditions allow nested logical expressions to build sophisticated filters.
  • Scopes define reusable query snippets for common patterns such as amount thresholds or payment methods.
  • Batch processing with FindInBatches efficiently handles large result sets.
  • Counting and plucking simplify aggregate queries and column extraction.

Quick Start

Use the advanced query skill to fetch all paid orders over 1000 using predefined scopes.

Frequently Asked Questions about gorm-advanced-query

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

FAQPage Schema
How do I write subqueries in GORM without raw SQL?

GORM allows you to build subqueries directly within WHERE or FROM clauses, eliminating manual SQL string concatenation. This enables complex data retrieval scenarios without writing verbose raw SQL queries.

How does row locking work in GORM for concurrent updates?

Row locking in GORM provides FOR UPDATE and FOR SHARE locks with options like NOWAIT and SKIP LOCKED. This ensures safe concurrent updates by controlling database row access during transaction processing.

What is the best way to handle large result sets in GORM?

Batch processing with FindInBatches is the best way to handle large result sets in GORM. It efficiently processes data in chunks, preventing memory exhaustion during extensive database retrieval operations.

How do I create reusable query filters in GORM?

GORM scopes define reusable query snippets for common filtering patterns like amount thresholds or payment methods. Group conditions also allow nested logical expressions to build sophisticated filters.

Can GORM automatically select specific columns for smaller structs?

GORM supports smart field selection, automatically selecting only required columns when mapping results to smaller structs. This optimizes queries by avoiding unnecessary data transfer from the database.