db

package
v0.0.0-...-b672b9b Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(db *gorm.DB) error

Bootstrap database state.

Apply migrations and seed with initial data if missing. The operation is idempotent and should do nothing on an already set up database.

func Pat

func Pat(tx *gorm.DB, id CatID) error

Pat records a new pat for the given Cat.

func Postgres

func Postgres(dsn string) (*gorm.DB, error)

Postgres connects to a PostgreSQL database.

Types

type Cat

type Cat struct {
	ID        CatID     // Unique identifier of the cat, must be URL-safe.
	Name      string    // Human-readable name of the cat.
	Pats      uint64    // Total number of pats received by the cat.
	LatestPat time.Time // Time when the latest pat was received.
}

Cat represents a database record about a single cat.

func CatByID

func CatByID(tx *gorm.DB, id CatID) (Cat, error)

CatByID queries the cat with the given ID from the database.

func (Cat) Mood

func (c Cat) Mood() Mood

Mood corresponding to Cat's current state.

type CatID

type CatID string

CatID is the type for Cat record's primary key and unique identifier.

const SplotchID CatID = "splotch"

SplotchID is the identifier of the OG, Splotch `Pat Junkie` the Cat.

func (CatID) Name

func (id CatID) Name() string

func (CatID) Seed

func (id CatID) Seed(cue string) []byte

Seed returns the noise seed for the cat, given noise type.

type Mood

type Mood string

Mood represents Cat's current state of mind.

const (
	MoodIdle      Mood = "idle"
	MoodIdleBlink Mood = "idle_blink"
	MoodIdleHappy Mood = "idle_happy"
	MoodImpatient Mood = "impatient"
	MoodPat       Mood = "pat"
	MoodSecret    Mood = "secret"
)

Directories

Path Synopsis
Package dbtest contains database utilities for use in tests.
Package dbtest contains database utilities for use in tests.

Jump to

Keyboard shortcuts

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