mysql

package
v0.0.0-...-91c0e42 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host     string `json:"host"`
	Username string `json:"username"`
	Password string `json:"password"`
	Database string `json:"database"`
}

Config contains the configuration for a MySQL database connection.

type MySQL

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

MySQL maintains the connection to a MySQL database.

func (*MySQL) Close

func (m *MySQL) Close()

Close cleanly closes the database connection.

func (m *MySQL) CreateShortLink(sl *shortlink.ShortLink) (*shortlink.ShortLink, error)
func (m *MySQL) DeleteShortLink(id int) error
func (m *MySQL) GetShortLink(id, root, short string) (*shortlink.ShortLink, error)

GetShortLink gets a short link object from database by id, root link or short link, depending on which was passed first (in this order). If no short link was found, no error will be returned and the returned short link object will be nil.

func (*MySQL) GetShortLinkCount

func (m *MySQL) GetShortLinkCount() (int, error)

GetShortLinkCount returns the number of short link entries in the database.

func (m *MySQL) GetShortLinks(from, limit int) ([]*shortlink.ShortLink, error)

func (*MySQL) Open

func (m *MySQL) Open(cfg interface{}) error

Open attempts to stablishes a connection to a MySQL database.

func (m *MySQL) UpdateShortLink(id int, updated *shortlink.ShortLink) error

Jump to

Keyboard shortcuts

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