entity

package
v0.0.0-...-cba693c Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game struct {
	bun.BaseModel `bun:"table:games"`

	Id         int64        `bun:"id,pk,autoincrement"`
	UserId     int64        `bun:"user_id,notnull"`
	WordId     int          `bun:"word_id,notnull"`
	GuessLimit int8         `bun:"guess_limit,notnull"`
	IsPlaying  bool         `bun:"is_playing,notnull,default:true"`
	IsWon      sql.NullBool `bun:"is_won"`
	CreatedAt  time.Time    `bun:"created_at,notnull"`
	UpdatedAt  time.Time    `bun:"updated_at,notnull"`

	Guesses []*Guess `bun:"rel:has-many,join:id=game_id"`
	Word    *Word    `bun:"rel:belongs-to,join:word_id=id"`
}

func NewGame

func NewGame(word *Word, currentUser *User) *Game

func (*Game) AddGuess

func (g *Game) AddGuess(word *Word) *Guess

type Guess

type Guess struct {
	bun.BaseModel `bun:"table:guesses"`

	Id        int64     `bun:"id,pk,autoincrement"`
	GameId    int64     `bun:"game_id,notnull"`
	WordId    int       `bun:"word_id,notnull"`
	CreatedAt time.Time `bun:"created_at,notnull"`

	Word *Word `bun:"rel:belongs-to,join:word_id=id"`
}

type User

type User struct {
	bun.BaseModel `bun:"table:users"`

	Id              int64        `bun:"id,pk,autoincrement"`
	Name            string       `bun:"name,notnull"`
	Email           string       `bun:"email,notnull,unique"`
	EmailVerifiedAt bun.NullTime `bun:"email_verified_at"`
	Password        string       `bun:"password,notnull"`
	CreatedAt       time.Time    `bun:"created_at,notnull"`
	UpdatedAt       time.Time    `bun:"updated_at,notnull"`
}

func NewUser

func NewUser(name string, email string, rawPassword string) (*User, error)

func (*User) IsPasswordMatch

func (user *User) IsPasswordMatch(password string) bool

type Word

type Word struct {
	bun.BaseModel `bun:"table:words"`

	Id        int       `bun:"id,pk,autoincrement"`
	Word      string    `bun:"word,notnull"`
	CreatedAt time.Time `bun:"created_at,notnull"`
}

func NewWord

func NewWord(word string) *Word

func (*Word) AsRunes

func (w *Word) AsRunes() []rune

Jump to

Keyboard shortcuts

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