mysql

package
v0.0.0-...-0bfac37 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStorage

func NewStorage(cfg *Config) (storage.Storage, error)

NewStorage accepts a Config and returns a pointer to a new Storage.

Types

type Config

type Config struct {
	Username string
	Password string
	Host     string
	Port     string
	Database string
}

Config contains configuration values used by mysql.

type Storage

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

Storage is an implementation of the generic interface storage.Storage for MySQL

func (*Storage) Create

func (s *Storage) Create(usr *server.User) error

Create a user based on a hydrated user model. Return an error on failure

func (*Storage) Delete

func (s *Storage) Delete(uid int) error

Delete soft deletes a user by setting the DeletedAt timestamp to now

func (*Storage) GetUser

func (s *Storage) GetUser(uid int) (*server.User, error)

GetUser based on their user id and return a model or error

func (*Storage) List

func (s *Storage) List(ctry string, off, lim int) (*[]server.User, error)

List the users with the optional field country - if this isn't provided all users will be returned

func (*Storage) Ping

func (s *Storage) Ping() error

Ping the database connection for a readiness check

func (*Storage) Update

func (s *Storage) Update(usr *server.User) error

Update a user model with its new set properties

Jump to

Keyboard shortcuts

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