Transactions
CLI-generated query methods and helpers accept any *gorm.DB, so they drop straight into your transaction logic.
Wrap reads and writes in one callback
err := db.Transaction(func(tx *gorm.DB) error { |
Nothing special is required: pass the transactional tx everywhere and return an error to roll back.
Compose multiple generated calls
err := db.Transaction(func(tx *gorm.DB) error { |
You can mix generated interface methods and field helpers inside the same transaction; both respect the current *gorm.DB state.
Next: see how the helpers manage Associations or return to the CLI overview.