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.