tessl install tessl/golang-gorm-io--gorm@1.31.0Full-featured ORM library for Golang with associations, hooks, transactions, migrations, and developer-friendly chainable API
Agent Success
Agent success rate when using this tile
81%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.13x
Baseline
Agent success rate without this tile
72%
Build a database audit logging system that tracks changes to user records. The system should log all create and update operations with timestamps, operation types, and the affected data.
AuditLog model with fields: ID, EntityType, EntityID, Operation (create/update), ChangedData (JSON), and Timestamp@generates
package main
import (
"time"
"gorm.io/gorm"
)
// User represents a user in the system
type User struct {
ID uint `gorm:"primarykey"`
Name string
Email string
UpdatedAt time.Time
CreatedAt time.Time
}
// AuditLog stores audit trail information
type AuditLog struct {
ID uint `gorm:"primarykey"`
EntityType string
EntityID uint
Operation string
ChangedData string // JSON string
Timestamp time.Time
}
// SetupAuditCallbacks configures the database to automatically create audit logs
func SetupAuditCallbacks(db *gorm.DB) error
// GetAuditLogs retrieves all audit logs for a specific user
func GetAuditLogs(db *gorm.DB, userID uint) ([]AuditLog, error)Provides ORM functionality for database operations and callback management.
@satisfied-by