Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Tags ¶
type Tags struct {
Column string
Skip, PK bool
AutoNowAdd, AutoNow bool
Embedded, Computed bool
Prefix string
// Generated is a column the database computes from the model's
// Generated() expression (orm:"generated"); Vector a vector's
// dimensions (orm:"vector:1536").
Generated bool
Vector int
// A relation: FK names the column holding the related row's key
// (orm:"fk:author_id"), Rel the related rows' column holding this
// row's key (orm:"rel:author_id"), M2M the table between
// (orm:"m2m:post_tags[,post_id,tag_id]", GORM's many2many) and
// JoinForeignKey and JoinReferences its columns for this row's key and
// the related row's. Related names the relation's inverse on the
// related model (orm:"related:members").
FK, Rel, M2M string
// Elements names the owner's JSON-array or comma-separated column
// holding the related rows' keys (orm:"elements:placement_id[,col]",
// col the related column, its primary key otherwise).
Elements string
JoinForeignKey, JoinReferences string
Related string
// Path is a lookup path through relations the field is read at
// (orm:"team__name"): a column read through a relation, or what a
// Values struct's field takes.
Path string
// Schema: a UNIQUE column, a VARCHAR size, a database type of your
// own, an index, and what deleting the related row does to this one
// (on a foreign key: cascade, set_null, restrict).
Unique, Index bool
UniqueIndex string // GORM's uniqueIndex name: columns sharing one are unique together
Size int
Type string
OnDelete string
Null bool // the column takes NULL though its Go type has no nil (FieldOptions only)
// CrossDB is a relation to a model on another database
// (orm:"crossdb"): no foreign key constraint, never joined.
CrossDB bool
// GormForeignKey is GORM's foreignKey, a Go field name, read as FK or
// Rel by the field's shape; References GORM's references, the Go
// field the key refers to.
GormForeignKey, References string
}
Tags is a field's column settings.
func Parse ¶
Parse reads a field's column settings from its name, tag and whether it is a time.Time: orm first, then db, then GORM's, so models written for GORM need no new tags. The ORM and its generator share it, so they agree on the columns.
func (Tags) Under ¶
Under is t as a names set reads it, v the field's tag of that set: "-" for no such field there, a lookup path (profile__first_name) for a column read through a relation, relation keys (foreignKey, references, many2many, joinForeignKey, joinReferences, fk, rel, m2m, related) and column merged over t's, else the field's column.
Click to show internal directories.
Click to hide internal directories.