gorm-update

Update database records with GORM across multiple SQL databases.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Updating records with GORM can be error‑prone: accidental global updates, missing where clauses, zero‑value fields being ignored, and hooks being unintentionally triggered.

Core Features & Use Cases

  • Save provides upsert behavior, inserting when the primary key does not exist.
  • Update updates a single column and requires a condition to avoid global updates.
  • Updates can modify multiple columns using a struct (ignores zero values) or a map (includes all values).
  • Select and Omit allow precise control over which fields are written.
  • Batch updates apply changes to many rows when no primary key is present.
  • Global update protection can be overridden with an explicit where clause, raw SQL, or a session that allows it.
  • SQL expressions enable mathematical updates directly in the query.
  • Subquery updates let you set a column based on another table’s data.
  • UpdateColumn and UpdateColumns bypass hooks and timestamp tracking.
  • Returning clauses retrieve the modified rows for databases that support it.
  • Common mistakes and fixes are documented for safe usage.

Quick Start

Ask the skill to set the name of user with ID 123 to 'Alice' using an update operation.

Frequently Asked Questions about gorm-update

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

FAQPage Schema
How do I update a single column safely in GORM without triggering a global update?

GORM requires a where clause when using the Update method for a single column to prevent accidental global updates. Adding an explicit condition ensures only targeted records are modified.

Why does GORM ignore zero values when updating with a struct?

GORM ignores zero-value fields when updating with a struct by design. To write all values including zero values, use a map with the Updates method instead of a struct.

How can I bypass hooks and timestamp tracking during a GORM update?

Use UpdateColumn or UpdateColumns to bypass hooks and timestamp tracking during a GORM update. These methods write changes directly without triggering automatic time tracking.

Can I perform batch updates across multiple rows in GORM?

Batch updates apply changes to many rows in GORM when no primary key is present in the query conditions. This allows efficient modification of bulk records.

How do I select or omit specific fields during a GORM update?

Use Select and Omit to control which fields are written during a GORM update. Select allows precise field inclusion while Omit excludes specific fields from the update operation.

Does GORM support subquery updates to set a column based on another table?

Subquery updates in GORM let you set a column based on another table's data. SQL expressions also enable mathematical updates directly in the query for supported databases.