model

package
v0.0.0-...-4e6b2c2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 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 ArtMovement

type ArtMovement struct {
	gorm.Model
	Name      string      `gorm:"type:varchar(64);not null;unique" json:"name"`
	Artists   []*Artist   `gorm:"many2many:artists_movements"`
	Paintings []*Painting `gorm:"many2many:paintings_styles"`
}

type ArtMovements

type ArtMovements struct {
	ArtMovements []string
}

func (*ArtMovements) UnmarshalCSV

func (paintingSchools *ArtMovements) UnmarshalCSV(csv string) (err error)

type Artist

type Artist struct {
	gorm.Model
	Name            string            `gorm:"type:varchar(128);not null;unique" json:"name"`
	OriginalName    string            `gorm:"type:varchar(128)" json:"original_name"`
	Nationalities   []*Nationality    `gorm:"many2many:artists_nationalities;association_autocreate:false"`
	PaintingSchools []*PaintingSchool `gorm:"many2many:artists_schools;association_autocreate:false"`
	ArtMovements    []*ArtMovement    `gorm:"many2many:artists_movements;association_autocreate:false"`
	Paintings       []*Painting       `gorm:"foreignkey:artist_id"`
	BirthDate       time.Time         `gorm:"type:date" json:"birth_date"`
	DeathDate       time.Time         `gorm:"type:date" json:"death_date"`
}

type ArtistCSV

type ArtistCSV struct {
	ID              int             `csv:"id"`
	Name            string          `csv:"name"`
	OriginalName    string          `csv:"original_name"`
	Nationalities   Nationalities   `csv:"nationalities"`
	PaintingSchools PaintingSchools `csv:"painting_schools"`
	ArtMovements    ArtMovements    `csv:"art_movements"`
	BirthDate       Date            `csv:"birth_date"`
	DeathDate       Date            `csv:"death_date"`
}

type ArtistsMovement

type ArtistsMovement struct {
	ArtistID      uint         `sql:"type:int REFERENCES artists(id)" json:"artist_id"`
	Artist        *Artist      `gorm:"foreignkey:id"`
	ArtMovementID uint         `sql:"type:int REFERENCES art_movements(id)" json:"art_movement_id"`
	ArtMovement   *ArtMovement `gorm:"foreignkey:id"`
}

type ArtistsNationality

type ArtistsNationality struct {
	ArtistID      uint         `sql:"type:int REFERENCES artists(id)" json:"artist_id"`
	Artist        *Artist      `gorm:"foreignkey:id"`
	NationalityID uint         `sql:"type:int REFERENCES nationality(id)" json:"nationality_id"`
	Nationality   *Nationality `gorm:"foreignkey:id"`
}

type ArtistsSchool

type ArtistsSchool struct {
	ArtistID         uint            `sql:"type:int REFERENCES artists(id)" json:"artist_id"`
	Artist           *Artist         `gorm:"foreignkey:id"`
	PaintingSchoolID uint            `sql:"type:int REFERENCES painting_schools(id)" json:"painting_school_id"`
	PaintingSchool   *PaintingSchool `gorm:"foreignkey:id"`
}

type Date

type Date struct {
	time.Time
}

func (*Date) MarshalCSV

func (date *Date) MarshalCSV() (string, error)

MarshalCSV converts the internal date as CSV string

func (*Date) UnmarshalCSV

func (date *Date) UnmarshalCSV(csv string) (err error)

UnmarshalCSV converts CSV string as the internal date

type Genre

type Genre struct {
	gorm.Model
	Name      string      `gorm:"type:varchar(64);not null;unique" json:"name"`
	Paintings []*Painting `gorm:"many2many:paintings_genres"`
}

type Image

type Image struct {
	gorm.Model
	Location   string    `gorm:"type:varchar(255);not null;unique" json:"name"`
	Width      int       `gorm:"type:int;" json:"width"`
	Height     int       `gorm:"type:int;" json:"height"`
	Painting   *Painting `gorm:"foreignkey:id"`
	PaintingID uint      `sql:"type:int REFERENCES paintings(id)" json:"painting_id"`
}

type Media

type Media struct {
	gorm.Model
	Name      string      `gorm:"type:varchar(32);not null;unique" json:"name"`
	Paintings []*Painting `gorm:"many2many:paintings_medias"`
}

type Nationalities

type Nationalities struct {
	Nationalities []string
}

func (*Nationalities) UnmarshalCSV

func (nationalities *Nationalities) UnmarshalCSV(csv string) (err error)

type Nationality

type Nationality struct {
	gorm.Model
	Demonym string    `gorm:"type:varchar(32);not null;unique" json:"demonym"`
	Artists []*Artist `gorm:"many2many:artists_nationalities"`
}

type Painting

type Painting struct {
	gorm.Model
	Name         string         `gorm:"type:varchar(128);not null;unique_index:artist_painting" json:"name"`
	OriginalName string         `gorm:"type:varchar(128)" json:"original_name"`
	Artist       *Artist        `gorm:"foreignkey:id"`
	ArtistID     uint           `gorm:"unique_index:artist_painting" sql:"type:int REFERENCES artists(id)" json:"artist_id"`
	Width        int            `gorm:"type:int" json:"width"`
	Height       int            `gorm:"type:int" json:"height"`
	Copyright    string         `gorm:"type:varchar(64)" json:"copyright"`
	Genres       []*Genre       `gorm:"many2many:paintings_genres;association_autocreate:false"`
	Styles       []*ArtMovement `gorm:"many2many:paintings_styles;association_autocreate:false"`
	Medias       []*Media       `gorm:"many2many:paintings_medias;association_autocreate:false"`
	Images       []*Image       `gorm:"foreignkey:painting_id"`
}

func (*Painting) Valid

func (p *Painting) Valid() bool

Validate returns if the painting is free for use or not

type PaintingSchool

type PaintingSchool struct {
	gorm.Model
	Name    string    `gorm:"type:varchar(64);not null;unique" json:"name"`
	Artists []*Artist `gorm:"many2many:artists_schools"`
}

type PaintingSchools

type PaintingSchools struct {
	PaintingSchools []string
}

func (*PaintingSchools) UnmarshalCSV

func (paintingSchools *PaintingSchools) UnmarshalCSV(csv string) (err error)

type PaintingsGenre

type PaintingsGenre struct {
	PaintingID uint      `sql:"type:int REFERENCES paintings(id)" json:"painting_id"`
	Painting   *Painting `gorm:"foreignkey:id"`
	GenreID    uint      `sql:"type:int REFERENCES genres(id)" json:"genre_id"`
	Genre      *Genre    `gorm:"foreignkey:id"`
}

type PaintingsMedias

type PaintingsMedias struct {
	PaintingID uint      `sql:"type:int REFERENCES paintings(id)" json:"painting_id"`
	Painting   *Painting `gorm:"foreignkey:id"`
	MediaID    uint      `sql:"type:int REFERENCES media(id)" json:"media_id"`
	Media      *Genre    `gorm:"foreignkey:id"`
}

type PaintingsStyle

type PaintingsStyle struct {
	PaintingID    uint         `sql:"type:int REFERENCES paintings(id)" json:"painting_id"`
	Painting      *Painting    `gorm:"foreignkey:id"`
	ArtMovementID uint         `sql:"type:int REFERENCES art_movements(id)" json:"art_movement_id"`
	ArtMovement   *ArtMovement `gorm:"foreignkey:id"`
}

type Result

type Result struct {
	Name  string
	Count int
}

Jump to

Keyboard shortcuts

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