dbmod

package
v0.0.0-...-9f93016 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	gorm.Model
	URL         string `gorm:"not null;uniqueIndex"`
	Title       string `gorm:"not null"`
	Description string
	Content     string
	PublishedAt uint64 // TODO: if not provided, set to CreatedAt
	ModifiedAt  uint64
	Banner      string
	Authors     []Author     `gorm:"many2many:article_authors"`
	Tags        []Tag        `gorm:"many2many:article_tags"`
	Attachments []Attachment // uses ArticleID as FK by default
	FeedID      uint         // FK
}

func (*Article) BeforeCreate

func (this *Article) BeforeCreate(tx *gorm.DB) (err error)

type Attachment

type Attachment struct {
	gorm.Model
	URL       string `gorm:"not null;unique"`
	Length    uint64 // 1GB is 8589934592 bits (size units) @ 34 bits (binary length)
	Type      string
	ArticleID uint // FK
}

func (*Attachment) BeforeCreate

func (this *Attachment) BeforeCreate(tx *gorm.DB) (err error)

type Author

type Author struct {
	gorm.Model
	// unique because there no other distinguishing attributes,
	// and we will end up with duplicates
	Name string `gorm:"not null;unique"`
}

func (*Author) BeforeCreate

func (this *Author) BeforeCreate(tx *gorm.DB) (err error)

type Feed

type Feed struct {
	gorm.Model
	URL         string `gorm:"not null;uniqueIndex"`
	Title       string
	Description string
	Language    string
	Tags        []Tag     `gorm:"many2many:feed_tags"`
	Articles    []Article // one-to-many; uses FeedID as FK by default
}

func (*Feed) BeforeCreate

func (this *Feed) BeforeCreate(tx *gorm.DB) (err error)

type Pattern

type Pattern struct {
	gorm.Model
	Name        string `gorm:"not null;unique"`
	Description string `gorm:"not null"`
	Pattern     string `gorm:"not null;unique"`
	Tags        []Tag  `gorm:"many2many:tag_patterns"`
}

func ToPattern

func ToPattern(name string, desc string, pattern string, tags []string) Pattern

func (*Pattern) BeforeCreate

func (this *Pattern) BeforeCreate(tx *gorm.DB) (err error)

type Tag

type Tag struct {
	gorm.Model
	Name string `gorm:"not null;uniqueIndex"`
}

func ToTag

func ToTag(name string) Tag

func ToTags

func ToTags(names []string) []Tag

func (*Tag) BeforeCreate

func (this *Tag) BeforeCreate(tx *gorm.DB) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL