model

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDatabase

func GetDatabase() (*pg.DB, error)

GetDatabase get a direct connection to the database using the config in viper. Used internally and for the migrate package

Types

type BoxomonDatastore

type BoxomonDatastore struct {
	// contains filtered or unexported fields
}

BoxomonDatastore PG-backed implementation of storing messages

func NewDatastoreFromConfig

func NewDatastoreFromConfig() (*BoxomonDatastore, error)

NewDatastoreFromConfig Create and return a datastore using the PG parameters sorted in viper config

func (*BoxomonDatastore) GetEncouragement

func (bdx *BoxomonDatastore) GetEncouragement(ctx context.Context) (*Encouragement, error)

GetEncouragement blah

type DummyBoxomonDatastore

type DummyBoxomonDatastore struct {
}

DummyBoxomonDatastore Dummy implementation of the BoxomonDatastore interface

func NewDummyDatastore

func NewDummyDatastore() *DummyBoxomonDatastore

NewDummyDatastore Create and return a dummy datastore

func (*DummyBoxomonDatastore) GetEncouragement

func (dbds *DummyBoxomonDatastore) GetEncouragement(context.Context) (*Encouragement, error)

GetEncouragement Return the same encouragement over and over.

type Encouragement

type Encouragement struct {
	ID int

	MessageID int
	Message   Message

	ImageID int
	Image   Image

	CreationDate time.Time `pg:"default:now()"`
}

Encouragement a combination of message and image to present

type Image

type Image struct {
	ID     int
	URL    string `pg:",unique"`
	Active bool
}

Image a definition of an image to show the user

type Message

type Message struct {
	ID     int
	Text   string `pg:",unique"`
	Active bool
}

Message a message to provide the user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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