repository

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Definition

type Definition struct {
	ID     DefinitionID   `gorm:"primaryKey;autoIncrement;not null"`
	WordID WordID         `gorm:"not null"`
	Type   sueno.WordType `gorm:"not null"`

	Definition  string `gorm:"not null;default:''"`
	Translation string `gorm:"not null"`

	Example            string `gorm:"not null;default:''"`
	ExampleTranslation string `gorm:"not null;default:''"`
}

type DefinitionID

type DefinitionID uint64

func ParseDefinitionID

func ParseDefinitionID(s string) (DefinitionID, error)

type Repository

type Repository interface {
	// WordRoot returns the words associated with the given root, sorted
	// by [Word.Type] and then by name.
	WordRoot(ctx context.Context, root string) (*WordRoot, error)

	CreateWord(context.Context, Word) (WordID, error)
	Word(context.Context, WordID) (*Word, error)
	SearchWord(context.Context, string) (*Word, error)
	SearchTranslation(context.Context, string) ([]TranslatedWord, error)
	CompoundWordsContaining(context.Context, WordID) ([]Word, error)
	DeleteWord(context.Context, WordID) error
}

type TranslatedWord

type TranslatedWord struct {
	Word
	MatchedDefinition Definition `gorm:"-"`
}

type Word

type Word struct {
	ID   WordID `gorm:"primaryKey;autoIncrement;not null"`
	Word string `gorm:"not null;unique"`
	Root string `gorm:"not null;default:''"`

	// CustomPlural allows overriding the plural form of the word.
	//
	// If this is empty, the plural form is grammatically derived from the word.
	//
	// Used for words such as 'ja' (plural: 'jaos').
	CustomPlural string `gorm:"not null;default:''"`

	Definitions   []Definition `gorm:"foreignKey:WordID;references:ID;constraint:OnDelete:cascade"`
	CompoundWords []Word       `gorm:"-"`
}

type WordID

type WordID uint64

func ParseWordID

func ParseWordID(s string) (WordID, error)

type WordRoot

type WordRoot struct {
	Root  string
	Words []Word
}

Directories

Path Synopsis
Package postgres provides a postgresql implementation of the [repository.Repository].
Package postgres provides a postgresql implementation of the [repository.Repository].

Jump to

Keyboard shortcuts

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