db

package
v0.0.0-...-e9d6e8f Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package db contains implementations for accessing back-end databases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Dialect     string
	DatabaseURI string
	Verbose     bool
}

Config provides database connection information.

func InitConfig

func InitConfig() (*Config, error)

InitConfig initializes the database configuration from external settings.

type Database

type Database struct {
	*gorm.DB
}

Database represents the data access object.

func New

func New(config *Config) (*Database, error)

New creates a new instance of the data access object given configuration settings.

func (*Database) CreatePlace

func (db *Database) CreatePlace(place *model.Place) error

CreatePlace add the provided place to the database.

func (*Database) DeletePlaceByID

func (db *Database) DeletePlaceByID(id uint) error

DeletePlaceByID removes a single place from the database given its identifier.

func (*Database) GetPlaceByID

func (db *Database) GetPlaceByID(id uint) (*model.Place, error)

GetPlaceByID retrieves a single place given its identifier.

func (*Database) GetPlaces

func (db *Database) GetPlaces() ([]*model.Place, error)

GetPlaces retrieves all available places from the database.

func (*Database) UpdatePlace

func (db *Database) UpdatePlace(place *model.Place) error

UpdatePlace updates the existing place in the database.

Jump to

Keyboard shortcuts

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