models

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindMarkdown   = "markdown"
	KindTweet      = "tweet"
	KindSlideShare = "slideshare"
	KindYoutube    = "youtube"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	ID           int64       `gorm:"column:id;primarykey" json:"id"`
	Kind         string      `gorm:"column:kind;type:varchar(24);not null" json:"kind"`
	URL          string      `gorm:"column:url;type:varchar(256);not null" json:"url"`
	Content      string      `gorm:"column:content;type:text" json:"content"`
	Title        string      `gorm:"column:title;type:varchar(256);not null;uniqueIndex" json:"title"`
	Tags         ArticleTags `gorm:"foreignKey:ArticleID" json:"tags"`
	Created      time.Time   `gorm:"column:created;type:datetime;not null" json:"created"`
	LastModified time.Time   `gorm:"column:last_modified;type:datetime;not null" json:"lastModified"`
}

func NewArticle

func NewArticle(kind, url, content, title string, tags []string) *Article

func (*Article) BeforeSave

func (a *Article) BeforeSave(db *gorm.DB) error

func (*Article) TableName

func (a *Article) TableName() string

type ArticleTag

type ArticleTag struct {
	ID        int64  `gorm:"column:id;primarykey" json:"id"`
	Tag       string `gorm:"column:tag;type:varchar(512);not null" json:"tag"`
	ArticleID int64  `gorm:"column:article_id;type:integer;not null" json:"articleID"`
}

func (*ArticleTag) TableName

func (t *ArticleTag) TableName() string

type ArticleTagCountDTO

type ArticleTagCountDTO struct {
	Tag   string `gorm:"column:tag" json:"tag"`
	Count int    `gorm:"column:cnt" json:"count"`
}

type ArticleTags

type ArticleTags []*ArticleTag

func (ArticleTags) ContainTag

func (t ArticleTags) ContainTag(tag string) bool

func (ArticleTags) ExtractIDs

func (t ArticleTags) ExtractIDs() []int64

func (ArticleTags) FilterExcluded

func (t ArticleTags) FilterExcluded(tags common.Strings) (ArticleTags, ArticleTags)

type Misc

type Misc struct {
	ID           int64     `gorm:"column:id;primarykey" json:"id"`
	Key          string    `gorm:"column:key;varchar(60);not null" json:"key"`
	Value        string    `gorm:"column:value;text;not null" json:"value"`
	Created      time.Time `gorm:"column:created;type:datetime;not null" json:"created"`
	LastModified time.Time `gorm:"column:last_modified;type:datetime;not null" json:"lastModified"`
}

func (*Misc) BeforeSave

func (m *Misc) BeforeSave(db *gorm.DB) error

func (*Misc) TableName

func (m *Misc) TableName() string

type Note

type Note struct {
	ID           int64      `gorm:"column:id;primarykey" json:"id"`
	Title        string     `gorm:"column:title;type:varchar(256);not null;uniqueIndex" json:"title"`
	Paragraphs   Paragraphs `gorm:"foreignKey:NoteID" json:"paragraphs"`
	Created      time.Time  `gorm:"column:created;type:datetime;not null" json:"created"`
	LastModified time.Time  `gorm:"column:last_modified;type:datetime;not null" json:"lastModified"`
}

func (*Note) BeforeSave

func (n *Note) BeforeSave(db *gorm.DB) error

func (*Note) GetContent

func (n *Note) GetContent() string

func (*Note) TableName

func (n *Note) TableName() string

type Notes

type Notes []*Note

func (Notes) ExtractParagraphs

func (n Notes) ExtractParagraphs() Paragraphs

type Paragraph

type Paragraph struct {
	ID                int64             `gorm:"column:id;primarykey" json:"id"`
	NoteID            int64             `gorm:"column:note_id;type:integer;not null" json:"noteID"`
	Seq               int               `gorm:"column:seq;type:integer;not null" json:"seq"`
	Content           string            `gorm:"column:content;type:text" json:"content"`
	ReferenceArticles ReferenceArticles `gorm:"foreignKey:ParagraphID" json:"referenceArticles"`
	ReferenceWebs     ReferenceWebs     `gorm:"foreignKey:ParagraphID" json:"referenceWebs"`
	Created           time.Time         `gorm:"column:created;type:datetime;not null" json:"created"`
	LastModified      time.Time         `gorm:"column:last_modified;type:datetime;not null" json:"lastModified"`
}

func (*Paragraph) BeforeSave

func (p *Paragraph) BeforeSave(db *gorm.DB) error

func (*Paragraph) TableName

func (p *Paragraph) TableName() string

type Paragraphs

type Paragraphs []*Paragraph

func (Paragraphs) ExtractIDs

func (p Paragraphs) ExtractIDs() []int64

func (Paragraphs) ExtractReferenceArticleArticleIDs

func (p Paragraphs) ExtractReferenceArticleArticleIDs() []int64

func (Paragraphs) ExtractReferenceArticleIDs

func (p Paragraphs) ExtractReferenceArticleIDs() []int64

func (Paragraphs) ExtractReferenceWebIDs

func (p Paragraphs) ExtractReferenceWebIDs() []int64

func (Paragraphs) MaxSeq

func (p Paragraphs) MaxSeq() int

type ReferenceArticle

type ReferenceArticle struct {
	ID           int64     `gorm:"column:id;primarykey" json:"id"`
	ParagraphID  int64     `gorm:"column:paragraph_id;type:integer;not null" json:"paragraphID"`
	ArticleID    int64     `gorm:"column:article_id;type:integer;not null" json:"articleID"`
	Created      time.Time `gorm:"column:created;type:datetime;not null" json:"created"`
	LastModified time.Time `gorm:"column:last_modified;type:datetime;not null" json:"lastModified"`
}

func (*ReferenceArticle) BeforeSave

func (a *ReferenceArticle) BeforeSave(db *gorm.DB) error

func (*ReferenceArticle) TableName

func (a *ReferenceArticle) TableName() string

type ReferenceArticles

type ReferenceArticles []*ReferenceArticle

func (ReferenceArticles) ContainArticleID

func (a ReferenceArticles) ContainArticleID(articleID int64) bool

func (ReferenceArticles) ExtractArticleIDs

func (a ReferenceArticles) ExtractArticleIDs() []int64

func (ReferenceArticles) ExtractIDs

func (a ReferenceArticles) ExtractIDs() []int64

type ReferenceWeb

type ReferenceWeb struct {
	ID           int64     `gorm:"column:id;primarykey" json:"id"`
	ParagraphID  int64     `gorm:"column:paragraph_id;type:integer;not null" json:"paragraphID"`
	URL          string    `gorm:"column:url;type:varchar(256);not null" json:"url"`
	Created      time.Time `gorm:"column:created;type:datetime;not null" json:"created"`
	LastModified time.Time `gorm:"column:last_modified;type:datetime;not null" json:"lastModified"`
}

func (*ReferenceWeb) BeforeSave

func (w *ReferenceWeb) BeforeSave(db *gorm.DB) error

func (*ReferenceWeb) TableName

func (w *ReferenceWeb) TableName() string

type ReferenceWebs

type ReferenceWebs []*ReferenceWeb

func (ReferenceWebs) ContainURL

func (a ReferenceWebs) ContainURL(url string) bool

func (ReferenceWebs) ExtractIDs

func (a ReferenceWebs) ExtractIDs() []int64

type Tags

type Tags []string

func (Tags) FilterExcluded

func (t Tags) FilterExcluded(articleTags ArticleTags) Tags

func (Tags) RemoveDuplicates added in v0.14.0

func (t Tags) RemoveDuplicates() Tags

Jump to

Keyboard shortcuts

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