models

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoMigrate

func AutoMigrate(db *gorm.DB) error

AutoMigrate performs the automatic migration of all GORM models.

Types

type Document

type Document struct {
	Model

	// A Namespace has many Documents.
	NamespaceID uint `gorm:"not null;index"`

	// A Document has many Texts.
	Texts []Text `gorm:"constraint:OnDelete:CASCADE"`

	// A Document has many Tags.
	Tags []Tag `gorm:"constraint:OnDelete:CASCADE"`
}

A Document from a namespace.

type Model

type Model struct {
	ID        uint      `gorm:"primaryKey"`
	CreatedAt time.Time `gorm:"not null;default:now()"`
	UpdatedAt time.Time `gorm:"not null;default:now()"`
}

Model is the basic struct embedded into all GORM models.

type Namespace

type Namespace struct {
	Model

	Name string `gorm:"not null;uniqueIndex"`

	// A Namespace has many Documents.
	Documents []Document `gorm:"constraint:OnDelete:CASCADE"`
}

A Namespace groups a set of Documents.

type Tag

type Tag struct {
	Model

	// A Document has many Tags.
	DocumentID uint `gorm:"not null;index"`

	Value string `gorm:"not null;index"`
}

A Tag is a simple label associated to a Document.

type Term

type Term struct {
	Model

	// A Text has many Terms.
	TextID uint `gorm:"not null;index"`

	// Value is the textual value of the term, which is a text token
	// such as a lemma, a single or compound word, etc.
	Value string `gorm:"not null;index"`

	// PositionInText allows the Term to be optionally associated to a
	// portion of Text. It is useful for highlighting.
	// The range represents the indices/positions of unicode code points
	// (runes) from the associated Text.
	PositionInText pgtype.Int8range `gorm:"type:int8range;null"`

	// Highlightable indicates whether this Term can be used as a candidate
	// for search results' highlighting.
	// It is ignored if PositionInText is null or an empty range.
	Highlightable bool `gorm:"not null;index"`
}

A Term from a text.

type Text

type Text struct {
	Model

	// A Document has many Texts.
	DocumentID uint `gorm:"not null;index;uniqueIndex:idx_unique_text_index_per_document"`

	Index int `gorm:"not null;index;uniqueIndex:idx_unique_text_index_per_document"`

	Value string `gorm:"not null"`

	// A Text has many Terms.
	Terms []Term `gorm:"constraint:OnDelete:CASCADE"`
}

A Text is a portion of a Document.

Jump to

Keyboard shortcuts

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