import "github.com/upper/db/adapter/cockroachdb"
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.
cockroachdb.go collection.go connection.go custom_types.go database.go template.go
const Adapter = `cockroachdb`
Adapter is the unique name that you can use to refer to this adapter.
func Array(in interface{}) sqlbuilder.ScannerValuer
Array returns a sqlbuilder.ScannerValuer for any given slice. Slice elements may require their own sqlbuilder.ScannerValuer.
DecodeJSONB is deprecated and going to be removed. Use JSONBValue instead.
EncodeJSONB is deprecated and going to be removed. Use ScanJSONB instead.
JSONBValue takes an interface and provides a driver.Value that can be stored as a JSONB column.
New creates a sqlbuilder.Sesion instance by wrapping a *sql.DB value.
NewTx creates a sqlbuilder.Tx instance by wrapping a *sql.Tx value.
Open establishes a connection to the database server and returns a db.Session instance (which is compatible with db.Session).
ScanJSONB decodes a JSON byte stream into the passed dst value.
BoolArray represents a one-dimensional array of int64s (`[]bool{}`) that is compatible with PostgreSQL's boolean type (`boolean[]`). BoolArray satisfies sqlbuilder.ScannerValuer.
Scan satisfies the sql.Scanner interface.
Value satisfies the driver.Valuer interface.
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(s string) (u ConnectionURL, err error)
ParseURL parses the given DSN into a ConnectionURL struct.
func (c ConnectionURL) String() (s string)
String reassembles the parsed PostgreSQL connection URL into a valid DSN.
type Float64Array pq.Float64Array
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 (f *Float64Array) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.
func (f Float64Array) Value() (driver.Value, error)
Value satisfies the driver.Valuer interface.
type GenericArray pq.GenericArray
GenericArray represents a one-dimensional array of any type (`[]interface{}`) that is compatible with PostgreSQL's array type. GenericArray satisfies sqlbuilder.ScannerValuer and its elements may need to satisfy sqlbuilder.ScannerValuer too.
func (g *GenericArray) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.
func (g GenericArray) Value() (driver.Value, error)
Value satisfies the driver.Valuer interface.
type Int64Array pq.Int64Array
Int64Array represents a one-dimensional array of int64s (`[]int64{}`) that is compatible with PostgreSQL's integer array (`integer[]`). Int64Array satisfies sqlbuilder.ScannerValuer.
func (i *Int64Array) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.
func (i Int64Array) Value() (driver.Value, error)
Value satisfies the driver.Valuer interface.
type JSONB struct {
V interface{}
}
JSONB represents a PostgreSQL's JSONB value: https://www.cockroachdb.org/docs/9.6/static/datatype-json.html. JSONB satisfies sqlbuilder.ScannerValuer.
MarshalJSON encodes the wrapper value as JSON.
Scan satisfies the sql.Scanner interface.
UnmarshalJSON decodes the given JSON into the wrapped value.
Value satisfies the driver.Valuer interface.
type JSONBArray []interface{}
JSONBArray represents an array of any type (`[]interface{}`) that is compatible with PostgreSQL's JSONB type. JSONBArray satisfies sqlbuilder.ScannerValuer.
func (a *JSONBArray) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.
func (a JSONBArray) Value() (driver.Value, error)
Value satisfies the driver.Valuer interface.
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 (obj *JSONBConverter) WrapValue(src interface{}) interface{}
WrapValue satisfies sqlbuilder.ValueWrapper
JSONBMap represents a map of interfaces with string keys (`map[string]interface{}`) that is compatible with PostgreSQL's JSONB type. JSONBMap satisfies sqlbuilder.ScannerValuer.
Scan satisfies the sql.Scanner interface.
Value satisfies the driver.Valuer interface.
type StringArray pq.StringArray
StringArray represents a one-dimensional array of strings (`[]string{}`) that is compatible with PostgreSQL's text array (`text[]`). StringArray satisfies sqlbuilder.ScannerValuer.
func (a *StringArray) Scan(src interface{}) error
Scan satisfies the sql.Scanner interface.
func (a StringArray) Value() (driver.Value, error)
Value satisfies the driver.Valuer interface.
Package cockroachdb imports 17 packages (graph). Updated 2021-01-15. Refresh now. Tools for package owners.