Documentation
¶
Overview ¶
Package document holds typed column descriptors and relation descriptors for the Document model.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ID = base.ID AuthorID = base.AuthorID Title = base.Title )
View Source
var Author = momo.Relation[models.Document, models.Author]{ Name: "Author", Kind: momo.BelongsTo, Parent: momo.TableRef{Name: "documents"}, Child: momo.TableRef{Name: "authors"}, ParentMeta: (*models.Document)(nil).MomoMeta(), ChildMeta: (*models.Author)(nil).MomoMeta(), ParentCols: []string{"author_id"}, ChildCols: []string{"id"}, ChildPK: []string{"id"}, ParentKey: func(p *models.Document) ([]any, bool) { if p.AuthorID == nil { return nil, false } return []any{*p.AuthorID}, true }, ChildKey: func(c *models.Author) ([]any, bool) { return []any{c.ID}, true }, SetParentKey: func(p *models.Document, k []any) { v0 := k[0].(int64) p.AuthorID = &v0 }, GetOne: func(p *models.Document) *models.Author { return p.Author }, SetOne: func(p *models.Document, c *models.Author) { p.Author = c }, }
Author is the belongs_to relation of Document.
View Source
var Comments = momo.Relation[models.Document, models.Comment]{ Name: "Comments", Kind: momo.HasMany, Parent: momo.TableRef{Name: "documents"}, Child: momo.TableRef{Name: "comments"}, ParentMeta: (*models.Document)(nil).MomoMeta(), ChildMeta: (*models.Comment)(nil).MomoMeta(), ParentCols: []string{"id"}, ChildCols: []string{"document_id"}, ChildPK: []string{"id"}, ParentKey: func(p *models.Document) ([]any, bool) { return []any{p.ID}, true }, ChildKey: func(c *models.Comment) ([]any, bool) { return []any{c.DocumentID}, true }, SetChildKey: func(c *models.Comment, k []any) { c.DocumentID = k[0].(int64) }, GetMany: func(p *models.Document) []models.Comment { return p.Comments }, SetMany: func(p *models.Document, cs []models.Comment) { p.Comments = cs }, }
Comments is the has_many relation of Document.
View Source
var Table = momo.TableRef{Name: "documents"}
Table is the base table reference.
View Source
var Tags = momo.Relation[models.Document, models.Tag]{ Name: "Tags", Kind: momo.ManyToMany, Parent: momo.TableRef{Name: "documents"}, Child: momo.TableRef{Name: "tags"}, ParentMeta: (*models.Document)(nil).MomoMeta(), ChildMeta: (*models.Tag)(nil).MomoMeta(), ParentCols: []string{"id"}, ChildCols: []string{"id"}, ChildPK: []string{"id"}, Through: &momo.Through{Table: momo.TableRef{Name: "taggings"}, ParentCols: []string{"document_id"}, ChildCols: []string{"tag_id"}}, ParentKey: func(p *models.Document) ([]any, bool) { return []any{p.ID}, true }, ChildKey: func(c *models.Tag) ([]any, bool) { return []any{c.ID}, true }, GetMany: func(p *models.Document) []models.Tag { return p.Tags }, SetMany: func(p *models.Document, cs []models.Tag) { p.Tags = cs }, }
Tags is the many2many relation of Document.
Functions ¶
func ColumnByName ¶
ColumnByName returns the typed column for an allowlisted external name. Names are matched exactly against database column names; relation fields and sensitive fields are not in the allowlist.
func ColumnNames ¶
func ColumnNames() []string
ColumnNames lists the allowlisted names in declaration order.
Types ¶
Click to show internal directories.
Click to hide internal directories.