models

package
v0.0.0-...-a4e7b05 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(migrater AutoMigrater)

Migrate migrates the DB

Types

type AutoMigrater

type AutoMigrater interface {
	AutoMigrate(values ...interface{}) *gorm.DB
}

AutoMigrater auto migrate the DB

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is the cmd configuration struct.

func NewConfig

func NewConfig() *Config

NewConfig returns the configuration object.

type Creator

type Creator interface {
	Create(value interface{}) *gorm.DB
}

Creator interface

type Database

type Database interface {
	Creator
	Finder
}

Database interface

type Finder

type Finder interface {
	Model(value interface{}) *gorm.DB
}

Finder interface

type Language

type Language struct {
	gorm.Model
	Source   string `gorm:"size:255;not null;index:source;" valid:"required"`
	Title    string `gorm:"size:255;not null;index:title" valid:"required"`
	Synonym  string `gorm:"size:255;"`
	Position uint   `gorm:"not null;index:position" valid:"type(uint)"`
	// contains filtered or unexported fields
}

Language is the service struct

func (*Language) BeforeSave

func (l *Language) BeforeSave() (err error)

BeforeSave runs before saving the object

func (*Language) GetAvailableSources

func (l *Language) GetAvailableSources() []string

GetAvailableSources returns the available sources

func (*Language) InitNameProcessor

func (l *Language) InitNameProcessor()

InitNameProcessor creates a name normalizer

func (*Language) Validate

func (l *Language) Validate(db *gorm.DB)

Validate validates struct

type LanguageRepository

type LanguageRepository struct {
	// contains filtered or unexported fields
}

LanguageRepository is the language repository struct

func NewLanguageRepository

func NewLanguageRepository(
	database Database, nameProcessor nameProcessor,
) *LanguageRepository

NewLanguageRepository return a new LanguageRepository

func (*LanguageRepository) AddLanguage

func (r *LanguageRepository) AddLanguage(
	source, title string, position uint,
) []error

AddLanguage creates a new language entry in the DB

func (*LanguageRepository) CreateLanguage

func (r *LanguageRepository) CreateLanguage(lang *Language) []error

CreateLanguage creates a new language

func (*LanguageRepository) NewLanguage

func (r *LanguageRepository) NewLanguage(
	source, title string, position uint,
) *Language

NewLanguage return a service object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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