postgres

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeckToDomainDeck

func DeckToDomainDeck(rd *Deck) (*deck.Deck, error)

DeckToDomainDeck transforms a repo deck to a domain deck.

Types

type Deck

type Deck struct {
	gorm.Model
	ID          string `gorm:"primaryKey"`
	Shuffled    bool
	Composition string         `gorm:"type:varchar(64)"`
	Codes       pq.StringArray `gorm:"type:varchar(3)[]"`
}

Deck represents a deck of cards.

func DomainDeckToDeck

func DomainDeckToDeck(d *deck.Deck) *Deck

DomainDeckToDeck transforms a domain deck to a repo deck.

type Repository

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

Repository is a PostgreSQL implementation of the deckr.Repository interface.

func NewRepository

func NewRepository(uri string, log *logger.Logger) (*Repository, error)

NewRepository creates a new PostgreSQL repository.

func (*Repository) Get

func (r *Repository) Get(_ context.Context, id string) (*deck.Deck, error)

Get returns the deck with the given id.

func (*Repository) Migrate

func (r *Repository) Migrate(_ context.Context) error

Migrate migratess the deck model.

func (*Repository) Save

func (r *Repository) Save(_ context.Context, d *deck.Deck) error

Save saves the given deck.

Jump to

Keyboard shortcuts

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