0Pricing
Go Academy · Lesson

Hooks and Scopes

Customize queries.

Hooks and Scopes

GORM offers two customization tools: hooks run code automatically around lifecycle events, and scopes package reusable query logic. Together they keep your data access clean and consistent.

What Are Hooks

Hooks are methods on your model that GORM calls before or after an operation: BeforeCreate, AfterCreate, BeforeUpdate, BeforeDelete, and more.

All lessons in this course

  1. Models and AutoMigrate
  2. CRUD Operations
  3. Associations
  4. Hooks and Scopes
← Back to Go Academy