check / check (push) Successful in 3m20s
Every reference from a model to the record it belongs to is now json:"-", so the webhook and target models (and the other parent and child pairs in internal/database) can no longer marshal each other in a loop. Preloading maps associations without reading json tags, so it still fills these references; a new test preloads a webhook with its targets and entrypoints and a target with its webhook, checks the references are filled, and checks the marshalled JSON leaves them out. Model: opus-5-5
22 lines
646 B
Go
22 lines
646 B
Go
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:"-"`
|
|
}
|