db.v3: upper.io/db.v3/mysql Index | Files

package mysql

import "upper.io/db.v3/mysql"

Package mysql wraps the github.com/go-sql-driver/mysql MySQL driver. See https://upper.io/db.v3/mysql for documentation, particularities and usage examples.

Index

Package Files

collection.go connection.go custom_types.go database.go mysql.go template.go tx.go

Constants

const Adapter = sqlDriver

Adapter is the public name of the adapter.

func DecodeJSON Uses

func DecodeJSON(dst interface{}, src interface{}) error

DecodeJSON is deprecated and going to be removed. Use JSONValue instead.

func EncodeJSON Uses

func EncodeJSON(i interface{}) (driver.Value, error)

EncodeJSON is deprecated and going to be removed. Use ScanJSON instead.

func JSONValue Uses

func JSONValue(i interface{}) (driver.Value, error)

JSONValue takes an interface and provides a driver.Value that can be stored as a JSON column.

func New Uses

func New(sess *sql.DB) (sqlbuilder.Database, error)

New wraps the given *sql.DB session and creates a new db session.

func NewTx Uses

func NewTx(sqlTx *sql.Tx) (sqlbuilder.Tx, error)

NewTx wraps a regular *sql.Tx transaction and returns a new upper-db transaction backed by it.

func Open Uses

func Open(settings db.ConnectionURL) (sqlbuilder.Database, error)

Open stablishes a new connection with the SQL server.

func ScanJSON Uses

func ScanJSON(dst interface{}, src interface{}) error

ScanJSON decodes a JSON byte stream into the passed dst value.

type ConnectionURL Uses

type ConnectionURL struct {
    User     string
    Password string
    Database string
    Host     string
    Socket   string
    Options  map[string]string
}

ConnectionURL implements a MySQL connection struct.

func ParseURL Uses

func ParseURL(s string) (conn ConnectionURL, err error)

ParseURL parses s into a ConnectionURL struct.

func (ConnectionURL) String Uses

func (c ConnectionURL) String() (s string)

type JSON Uses

type JSON struct {
    V interface{}
}

JSON represents a MySQL's JSON value: https://www.mysql.org/docs/9.6/static/datatype-json.html. JSON satisfies sqlbuilder.ScannerValuer.

func (JSON) MarshalJSON Uses

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON encodes the wrapper value as JSON.

func (*JSON) Scan Uses

func (j *JSON) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (*JSON) UnmarshalJSON Uses

func (j *JSON) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes the given JSON into the wrapped value.

func (JSON) Value Uses

func (j JSON) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

type JSONArray Uses

type JSONArray []interface{}

JSONArray represents an array of any type (`[]interface{}`) that is compatible with MySQL's JSON type. JSONArray satisfies sqlbuilder.ScannerValuer.

func (*JSONArray) Scan Uses

func (a *JSONArray) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (JSONArray) Value Uses

func (a JSONArray) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

type JSONConverter Uses

type JSONConverter struct {
}

JSONConverter provides a helper method WrapValue that satisfies sqlbuilder.ValueWrapper, can be used to encode Go structs into JSON MySQL types and vice versa.

Example:

type MyCustomStruct struct {
  ID int64 `db:"id" json:"id"`
  Name string `db:"name" json:"name"`
  ...
  mysql.JSONConverter
}

func (*JSONConverter) WrapValue Uses

func (obj *JSONConverter) WrapValue(src interface{}) interface{}

WrapValue satisfies sqlbuilder.ValueWrapper

type JSONMap Uses

type JSONMap map[string]interface{}

JSONMap represents a map of interfaces with string keys (`map[string]interface{}`) that is compatible with MySQL's JSON type. JSONMap satisfies sqlbuilder.ScannerValuer.

func (*JSONMap) Scan Uses

func (m *JSONMap) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (JSONMap) Value Uses

func (m JSONMap) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

Package mysql imports 19 packages (graph) and is imported by 1 packages. Updated 2018-11-26. Refresh now. Tools for package owners.