package database import "time" // APIKey represents an API key for a user. // // Key is a bearer credential, so it is never marshalled with the // model. A creation handler that has to show it once returns it in its // own response type. type APIKey struct { BaseModel UserID string `gorm:"type:uuid;not null" json:"userId"` Key string `gorm:"uniqueIndex;not null" json:"-"` Description string `json:"description"` LastUsedAt *time.Time `json:"lastUsedAt,omitempty"` // Relations. No model marshals the record it belongs to: // User.APIKeys leads back here, and the JSON could loop. User User `json:"-"` }