models

package
v0.0.0-...-0f828a4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlackCard

type BlackCard struct {
	ID     uint `gorm:"primarykey"`
	DeckID uint
	Deck   Deck   `gorm:"constraint:OnDelete:CASCADE;not null"`
	Text   string `gorm:"not null"`
	Blanks uint   `gorm:"not null"`
}

func (*BlackCard) BeforeSave

func (bc *BlackCard) BeforeSave(tx *gorm.DB) error

Sets the blank count before saving a black card.

type Deck

type Deck struct {
	ID         uint   `gorm:"primarykey"`
	Name       string `gorm:"not null"`
	Official   bool   `gorm:"default:0;not null"`
	OwnerID    sql.NullInt64
	Owner      User `gorm:"constraint:OnDelete:SET NULL"`
	BlackCards []BlackCard
	WhiteCards []WhiteCard
}

type Role

type Role string
const (
	Developer   Role = "developer"
	Contributor Role = "contributor"
	Supporter   Role = "supporter"
)

type SessionToken

type SessionToken struct {
	ID         uint      `gorm:"primarykey"`
	Token      string    `gorm:"index;unique;not null"`
	ValidUntil time.Time `gorm:"not null"`
	UserID     uint
	User       User `gorm:"constraint:OnDelete:CASCADE;not null"`
}

type User

type User struct {
	ID            uint   `gorm:"primarykey"`
	Username      string `gorm:"index;unique;not null"`
	Password      string `gorm:"not null"`
	Admin         bool
	Role          Role `gorm:"not null"`
	SessionTokens []SessionToken
	Decks         []Deck `gorm:"foreignKey:OwnerID"`
}

func (*User) IsPasswordEqual

func (u *User) IsPasswordEqual(password string) (bool, error)

Compares the supplied password with the password of the user instance.

type WhiteCard

type WhiteCard struct {
	ID     uint `gorm:"primarykey"`
	DeckID uint
	Deck   Deck   `gorm:"constraint:OnDelete:CASCADE;not null"`
	Text   string `gorm:"not null"`
}

Jump to

Keyboard shortcuts

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