postgresql

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(c *ConnectionConfig) (*gorm.DB, *sql.DB)

Connect establishes a database connection to the PostgreSQL instance

func Reset

func Reset(db *gorm.DB)

Reset drops all existing tables, and automigrates them again

Types

type BattlesRepository

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

BattlesRepository is the repository that abstracts access to the underlying database operations used to query and mutate data relating to battles. This implementation relies on GORM and also executes validations before interacting with the database

func NewBattlesRepository

func NewBattlesRepository(db *gorm.DB) *BattlesRepository

NewBattlesRepository returns a pointer to a ready-to-use postgresql.BattlesRepository

func (*BattlesRepository) CreateOne

func (r *BattlesRepository) CreateOne(data battles.CreationInput) (uuid.UUID, error)

CreateOne creates a battle in the database, together with entries in the corresponding tables that let us relate the battle with other factions and commanders. The operation returns the ID of the new battle

func (*BattlesRepository) FindMany

func (r *BattlesRepository) FindMany(query battles.FindManyQuery, page int) ([]battles.Battle, int, error)

FindMany does a paginated search of all battles matching the given query

func (*BattlesRepository) FindOne

FindOne finds the first battle in the database that matches the query, together with its related factions and commanders

type CommandersRepository

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

CommandersRepository is the repository that abstracts access to the underlying database operations used to query and mutate data relating to commanders. This implementation relies on GORM and also executes validations before interacting with the database

func NewCommandersRepository

func NewCommandersRepository(db *gorm.DB) *CommandersRepository

NewCommandersRepository returns a pointer to a ready-to-use postgresql.CommandersRepository

func (*CommandersRepository) CreateOne

CreateOne creates a commander in the database. The operation returns the ID of the new commander

func (*CommandersRepository) FindMany

FindMany does a paginated search of all commanders matching the given query

func (*CommandersRepository) FindOne

FindOne finds the first commander in the database that matches the query

type ConnectionConfig

type ConnectionConfig struct {
	Host string
	Port string
	Name string
	User string
	Pass string
}

ConnectionConfig is a struct that contains database connection configuration options

func DefaultTestConfig

func DefaultTestConfig() *ConnectionConfig

DefaultTestConfig exposes a ConnectionConfig set up to work with the default test environment

type FactionsRepository

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

FactionsRepository is the repository that abstracts access to the underlying database operations used to query and mutate data relating to factions. This implementation relies on GORM and also executes validations before interacting with the database

func NewFactionsRepository

func NewFactionsRepository(db *gorm.DB) *FactionsRepository

NewFactionsRepository returns a pointer to a ready-to-use postgresql.FactionsRepository

func (*FactionsRepository) CreateOne

func (r *FactionsRepository) CreateOne(data factions.CreationInput) (uuid.UUID, error)

CreateOne creates a faction in the database. The operation returns the ID of the new faction

func (*FactionsRepository) FindMany

func (r *FactionsRepository) FindMany(query factions.FindManyQuery, page int) ([]factions.Faction, int, error)

FindMany does a paginated search of all factions matching the given query

func (*FactionsRepository) FindOne

FindOne finds the first faction in the database that matches the query

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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