Documentation
¶
Overview ¶
Code generated by gombit make resource. DO NOT EDIT.
Code generated by gombit make resource. DO NOT EDIT.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Document ¶
type Document struct {
ID uint `gorm:"primaryKey" json:"id"`
CreatedAt time.Time
UpdatedAt time.Time
Title string `gorm:"size:255;not null"`
Attachment types.File `` /* 147-byte string literal not displayed */
Cover *types.Image `gorm:"size:512;uniqueIndex" storage:"prefix=document/cover/;max_bytes=2097152"`
}
Document is a model with storage-backed fields, as `gombit make resource Document title:string:required attachment:file:required cover:image` scaffolds it: each file column holds an object key, under a prefix the field owns (its storage tag), with a unique index so one record owns each file. The generated handler grants direct uploads for the fields, accepts only uploads that pass the policy, and returns file objects on reads.
type DocumentHooks ¶
type DocumentHooks interface {
BeforeCreate(ctx context.Context, row *Document, body documentCreateBody) error
}
DocumentHooks are the customization points for the generated Document handler. The generated handler owns the invariant CRUD sequence and calls these; set server-managed columns (tenant, owner, …) in BeforeCreate rather than editing generated plumbing.
type Handler ¶
type Handler struct {
DB *gorm.DB
Hooks DocumentHooks
// Store holds the files of the resource's file fields.
Store storage.Storage
// Claims owns them: a record holds its files' keys (storage/claims).
Claims *claims.Claims
}
Handler serves Document HTTP operations over GORM. Register wires DB and Hooks.
type Hooks ¶
type Hooks struct{}
Hooks implements DocumentHooks. This file is generated once and is yours to edit: set server-managed columns (tenant, owner, timestamps not handled by GORM, …) on row in BeforeCreate. Regeneration does not overwrite it.
func (Hooks) BeforeCreate ¶
BeforeCreate runs after the request is mapped onto row and before it is persisted. The default is a no-op; add server-derived values here.