Documentation ¶
Overview ¶
Package simplemaria offers a simple way to use a MySQL/MariaDB database. This database backend is interchangeable with xyproto/simpleredis and xyproto/simplebolt, since they all use xyproto/pinterface.
Index ¶
- Constants
- Variables
- func Decode(code *string) error
- func Encode(value *string) error
- func TestConnection() (err error)
- func TestConnectionHost(connectionString string) (err error)
- func TestConnectionHostWithDSN(connectionString string) (err error)
- type HashMap
- func (h *HashMap) All() ([]string, error)
- func (h *HashMap) Clear() error
- func (h *HashMap) Del(owner string) error
- func (h *HashMap) DelKey(owner, key string) error
- func (h *HashMap) Exists(owner string) (bool, error)
- func (h *HashMap) Get(owner, key string) (string, error)
- func (h *HashMap) GetAll() ([]string, error)
- func (h *HashMap) Has(owner, key string) (bool, error)
- func (h *HashMap) Keys(owner string) ([]string, error)
- func (h *HashMap) Remove() error
- func (h *HashMap) Set(owner, key, value string) error
- type Host
- type KeyValue
- type List
- func (l *List) Add(value string) error
- func (l *List) All() ([]string, error)
- func (l *List) Clear() error
- func (l *List) GetAll() ([]string, error)
- func (l *List) GetLast() (string, error)
- func (l *List) GetLastN(n int) ([]string, error)
- func (l *List) Last() (string, error)
- func (l *List) LastN(n int) ([]string, error)
- func (l *List) Remove() error
- type MariaCreator
- type Set
Constants ¶
const (
// Version number. Stable API within major version numbers.
Version = 3.2
)
Variables ¶
var Verbose = false
Functions ¶
func Encode ¶
MariaDB/MySQL does not handle some characters well. Compressing and hex encoding the value is one of many possible ways to avoid this. Using BLOB fields and different datatypes is another.
func TestConnection ¶
func TestConnection() (err error)
Test if the local database server is up and running.
func TestConnectionHost ¶
Test if a given database server is up and running. connectionString may be on the form "username:password@host:port/database".
func TestConnectionHostWithDSN ¶
Test if a given database server is up and running.
Types ¶
type HashMap ¶
type HashMap dbDatastructure
func (*HashMap) DelKey ¶
Remove a key for an entry in a hashmap (for instance the email field for a user)
func (*HashMap) Get ¶
Get a value from a hashmap given the element id (for instance a user id) and the key (for instance "password").
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host represents a specific database at a database host
func NewHost ¶
Create a new database connection. connectionString may be on the form "username:password@host:port/database".
func NewHostWithDSN ¶
Create a new database connection with a valid DSN.
func (*Host) SelectDatabase ¶
Select a different database. Create the database if needed.
func (*Host) SetRawUTF8 ¶
Should the UTF-8 data be raw, and not hex encoded and compressed?
type KeyValue ¶
type KeyValue dbDatastructure
func NewKeyValue ¶
Create a new key/value
type List ¶
type List dbDatastructure
type MariaCreator ¶
type MariaCreator struct {
// contains filtered or unexported fields
}
func NewCreator ¶
func NewCreator(host *Host) *MariaCreator
func (*MariaCreator) NewHashMap ¶
func (m *MariaCreator) NewHashMap(id string) (pinterface.IHashMap, error)
func (*MariaCreator) NewKeyValue ¶
func (m *MariaCreator) NewKeyValue(id string) (pinterface.IKeyValue, error)
func (*MariaCreator) NewList ¶
func (m *MariaCreator) NewList(id string) (pinterface.IList, error)
func (*MariaCreator) NewSet ¶
func (m *MariaCreator) NewSet(id string) (pinterface.ISet, error)