Documentation ¶
Overview ¶
Package cockroachdb wraps the github.com/lib/pq driver and provides a compatibility later with CockroachDB. See https://github.com/upper/db/adapter/cockroachdb for documentation, particularities and usage examples.
Index ¶
- Constants
- func DecodeJSONB(dst interface{}, src interface{}) error
- func EncodeJSONB(i interface{}) (driver.Value, error)
- func JSONBValue(i interface{}) (driver.Value, error)
- func New(sqlDB *sql.DB) (db.Session, error)
- func NewTx(sqlTx *sql.Tx) (sqlbuilder.Tx, error)
- func Open(connURL db.ConnectionURL) (db.Session, error)
- func ScanJSONB(dst interface{}, src interface{}) error
- type BoolArray
- type Bytea
- type ByteaArray
- type ConnectionURL
- type Float32Array
- type Float64Array
- type Int32Array
- type Int64Array
- type JSONB
- type JSONBArray
- type JSONBConverter
- type JSONBMap
- type StringArray
Constants ¶
const Adapter = `cockroachdb`
Adapter is the unique name that you can use to refer to this adapter.
Variables ¶
This section is empty.
Functions ¶
func DecodeJSONB ¶
func DecodeJSONB(dst interface{}, src interface{}) error
DecodeJSONB is deprecated and going to be removed. Use JSONBValue instead.
func EncodeJSONB ¶
EncodeJSONB is deprecated and going to be removed. Use ScanJSONB instead.
func JSONBValue ¶
JSONBValue takes an interface and provides a driver.Value that can be stored as a JSONB column.
func NewTx ¶
func NewTx(sqlTx *sql.Tx) (sqlbuilder.Tx, error)
NewTx creates a sqlbuilder.Tx instance by wrapping a *sql.Tx value.
Types ¶
type BoolArray ¶
type BoolArray []bool
BoolArray represents a one-dimensional array of int64s (`[]bool{}`) that is compatible with PostgreSQL's boolean type (`boolean[]`). BoolArray satisfies sqlbuilder.ScannerValuer.
type ByteaArray ¶ added in v4.5.0
type ByteaArray [][]byte
ByteaArray represents a one-dimensional array of strings (`[]string{}`) that is compatible with PostgreSQL's text array (`text[]`). ByteaArray satisfies sqlbuilder.ScannerValuer.
func (*ByteaArray) Scan ¶ added in v4.5.0
func (ba *ByteaArray) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.
type ConnectionURL ¶
type ConnectionURL struct { User string Password string Host string Socket string Database string Options map[string]string }
ConnectionURL represents a parsed CockroachDB connection URL.
You can use a ConnectionURL struct as an argument for Open:
var settings = cockroachdb.ConnectionURL{ Host: "localhost", // Database server IP or host name. Database: "peanuts", // Database name. User: "cbrown", // Optional user name. Password: "snoopy", // Optional user password. } sess, err = cockroachdb.Open(settings)
If you already have a valid DSN, you can use ParseURL to convert it into a ConnectionURL before passing it to Open.
func ParseURL ¶
func ParseURL(s string) (u ConnectionURL, err error)
ParseURL parses the given DSN into a ConnectionURL struct.
func (ConnectionURL) String ¶
func (c ConnectionURL) String() (s string)
String reassembles the parsed PostgreSQL connection URL into a valid DSN.
type Float32Array ¶ added in v4.5.0
type Float32Array []float32
Float32Array represents a one-dimensional array of float32s (`[]float32{}`) that is compatible with PostgreSQL's double precision array (`double precision[]`). Float32Array satisfies sqlbuilder.ScannerValuer.
func (*Float32Array) Scan ¶ added in v4.5.0
func (f32a *Float32Array) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.
type Float64Array ¶
type Float64Array []float64
Float64Array represents a one-dimensional array of float64s (`[]float64{}`) that is compatible with PostgreSQL's double precision array (`double precision[]`). Float64Array satisfies sqlbuilder.ScannerValuer.
func (*Float64Array) Scan ¶
func (f64a *Float64Array) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.
type Int32Array ¶ added in v4.5.0
type Int32Array []int32
Int32Array represents a one-dimensional array of int32s (`[]int32{}`) that is compatible with PostgreSQL's integer array (`integer[]`). Int32Array satisfies sqlbuilder.ScannerValuer.
func (*Int32Array) Scan ¶ added in v4.5.0
func (i32a *Int32Array) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.
type Int64Array ¶
type Int64Array []int64
Int64Array represents a one-dimensional array of int64s (`[]int64{}`) that is compatible with PostgreSQL's integer array (`integer[]`). Int64Array satisfies sqlbuilder.ScannerValuer.
func (*Int64Array) Scan ¶
func (i64a *Int64Array) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.
type JSONB ¶
type JSONB struct {
Data interface{}
}
JSONB represents a PostgreSQL's JSONB value: https://www.postgresql.org/docs/9.6/static/datatype-json.html. JSONB satisfies sqlbuilder.ScannerValuer.
func (JSONB) MarshalJSON ¶
MarshalJSON encodes the wrapper value as JSON.
func (*JSONB) UnmarshalJSON ¶
UnmarshalJSON decodes the given JSON into the wrapped value.
type JSONBArray ¶
type JSONBArray []interface{}
JSONBArray represents an array of any type (`[]interface{}`) that is compatible with PostgreSQL's JSONB type. JSONBArray satisfies sqlbuilder.ScannerValuer.
func (*JSONBArray) Scan ¶
func (a *JSONBArray) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.
type JSONBConverter ¶
type JSONBConverter struct { }
JSONBConverter provides a helper method WrapValue that satisfies sqlbuilder.ValueWrapper, can be used to encode Go structs into JSONB PostgreSQL types and vice versa.
Example:
type MyCustomStruct struct { ID int64 `db:"id" json:"id"` Name string `db:"name" json:"name"` ... cockroachdb.JSONBConverter }
func (*JSONBConverter) ConvertValue ¶ added in v4.5.0
func (*JSONBConverter) ConvertValue(src interface{}) interface { sql.Scanner driver.Valuer }
type JSONBMap ¶
type JSONBMap map[string]interface{}
JSONBMap represents a map of interfaces with string keys (`map[string]interface{}`) that is compatible with PostgreSQL's JSONB type. JSONBMap satisfies sqlbuilder.ScannerValuer.
type StringArray ¶
type StringArray []string
StringArray represents a one-dimensional array of strings (`[]string{}`) that is compatible with PostgreSQL's text array (`text[]`). StringArray satisfies sqlbuilder.ScannerValuer.
func (*StringArray) Scan ¶
func (sa *StringArray) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.