database

package
v0.0.0-...-2b2b3c0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDSN = "host=localhost user=bogglr password=bogglr dbname=bogglr sslmode=disable"

Functions

func Migrate

func Migrate(db *DB) error

Types

type Board

type Board pq.StringArray

func (Board) Dump

func (b Board) Dump() boggle.Board

func (*Board) Load

func (b *Board) Load(board boggle.Board)

func (*Board) Scan

func (b *Board) Scan(src interface{}) error

func (Board) Value

func (b Board) Value() (driver.Value, error)

type DB

type DB = gorm.DB

func Open

func Open(dsn string) (*DB, error)

type Game

type Game struct {
	ID    int   `gorm:"primaryKey;not null"`
	Board Board `gorm:"not null;type:varchar(16)[16];check:cardinality(board) <= 16"`
}

func (*Game) DumpBoard

func (g *Game) DumpBoard() boggle.Board

func (*Game) LoadBoard

func (g *Game) LoadBoard(board boggle.Board)

type Path

type Path []Point

Path is a PostgreSQL open path.

func (*Path) Scan

func (p *Path) Scan(src interface{}) error

func (Path) Value

func (p Path) Value() (driver.Value, error)

type Player

type Player struct {
	ID    int    `gorm:"primaryKey;not null"`
	Name  string `gorm:"not null"`
	Words []Word `gorm:"many2many:word_players"`
}

type Point

type Point boggle.Point

Point is a PostgreSQL point (closed notation).

func (*Point) Scan

func (p *Point) Scan(src interface{}) error

func (Point) Value

func (p Point) Value() (driver.Value, error)

type Word

type Word struct {
	ID      int `gorm:"primaryKey;not null"`
	GameID  int `gorm:"not null;uniqueKey:idx_word"`
	Game    *Game
	Path    Path     `gorm:"not null;uniqueKey:idx_word"`
	Players []Player `gorm:"many2many:word_players"`
}

type WordPlayer

type WordPlayer struct {
	WordID   int `gorm:"primaryKey;not null"`
	Word     *Word
	PlayerID int `gorm:"primaryKey;not null"`
	Player   *Player
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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