database

package
v0.0.0-...-f8deed7 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToDatabase

func ConnectToDatabase(databaseURL string, databaseName string) (*pgxpool.Pool, error)

func CreateConnPool

func CreateConnPool(databaseURL string) (*pgxpool.Pool, error)

func CreateDatabaseIfNotExists

func CreateDatabaseIfNotExists(dbpool *pgxpool.Pool, dbname string) error

func CreatePokemon

func CreatePokemon(dbpool *pgxpool.Pool, tablename string, pokemon *models.Pokemon) error

CreatePokemon creates a new Pokémon record in the database

func CreatePokemonTable

func CreatePokemonTable(dbpool *pgxpool.Pool, tablename string) error

create the Pokemontable for usage in the database initialization here we define the Primary key, as well as unique values.

func DeletePokemon

func DeletePokemon(dbpool *pgxpool.Pool, tablename string, name string) error

DeletePokemon deletes a Pokémon record from the database based on the provided name The Exec function is used, because there are no rows returned

func GetPokemon

func GetPokemon(dbpool *pgxpool.Pool, tablename string, name string) (*models.Pokemon, error)

GetPokemon retrieves a Pokémon record from the database based on the provided ID

func GetPokemons

func GetPokemons(dbpool *pgxpool.Pool, tablename string) ([]models.Pokemon, error)

GetPokemons returns a slice of Pokémon record from the database

func InitDatabase

func InitDatabase(config *models.AppConfig) (*pgxpool.Pool, error)

func UpdatePokemon

func UpdatePokemon(dbpool *pgxpool.Pool, tablename string, pokemon *models.Pokemon) error

UpdatePokemon updates an existing Pokémon record in the database this uses the name to update, this is okay since its unique in the database.

func UpdatePokemonbyID

func UpdatePokemonbyID(dbpool *pgxpool.Pool, tablename string, id int, pokemon *models.Pokemon) error

UpdatePokemonbyID updates based on the ID in the database.

Types

This section is empty.

Jump to

Keyboard shortcuts

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