backend

package
v0.0.0-...-c948546 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend is the struct which contains the database client and the config.

func New

func New() (*Backend, error)

New returns a new backend struct mainly containing a database connection, according to the read config file.

func (*Backend) AddGarden

func (b *Backend) AddGarden(g *Garden) (uuid.UUID, error)

AddGarden adds a new garden to the database. It returns the uuid of the added garden.

func (*Backend) DeleteGarden

func (b *Backend) DeleteGarden(id uuid.UUID) (uuid.UUID, error)

DeleteGarden deletes a garden corresponding to the given uuid from the database. It returns the uuid of the deleted garden.

func (*Backend) EditGarden

func (b *Backend) EditGarden(id uuid.UUID, g *Garden) (uuid.UUID, error)

EditGarden updates the garden corresponding to the given id with the updated value of name and color. It returns the uuid of the updated faction.

func (*Backend) GetGarden

func (b *Backend) GetGarden(id uuid.UUID) (*Garden, error)

GetGarden returns the garden corresponding to the given uuid. It makes a SELECT query on the database, limited to one result.

type Config

type Config struct {
	// DBName is the database name
	DBName string `json:"db_name"`
	// User is the database user
	User string `json:"user"`
	// Password is the database password for the used user
	Password string `json:"password"`
	// Addr is the database address
	Addr string `json:"addr"`
	// Port is the database port
	Port int `json:"port"`
	// SkipVerify is a bool which determines if the backend
	// must skips the ssl mode or not.
	SkipVerify bool `json:"skip_verify,omitempty"`
	// contains filtered or unexported fields
}

Config is the backend configuration.

func (*Config) Valid

func (c *Config) Valid() error

Valid returns an error if the config is not valid.

type Garden

type Garden struct {
	// UUID is the garden uuid.
	UUID uuid.UUID `json:"uuid" description:"Garden UUID"`

	// Name is the garden name.
	Name string `json:"name" description:"Garden name"`

	// Address is the garden address.
	Address string `json:"address" description:"Garden address"`

	// Size is the garden size.
	Size int `json:"size" description:"Garden size"`

	// Floor is the garden floor quality.
	Floor int `json:"floor" description:"Garden floor quality"`

	// HasTools defined if the tools are provided.
	HasTools bool `json:"hasTools" description:"Defines if the tools are provided"`

	// HasWater defines if the garden has a water access.
	HasWater bool `json:"hasWater" description:"Defines if the garden has a water access"`

	// HasShed defines if the garden has a shed.
	HasShed bool `json:"hasShed" description:"Defines if the garden has a shed"`
}

Garden is the struct containing informations about a faction.

Jump to

Keyboard shortcuts

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