Documentation ¶
Index ¶
- func JSONValue(v interface{}) (driver.Value, error)
- func Nullable(typ interface{}) interface{}
- func ScanJSON(v interface{}, dst interface{}) error
- type Float32Array
- type Int16Array
- type Int32Array
- type Int8Array
- type IntArray
- type SQLType
- type URL
- type Uint16Array
- type Uint32Array
- type Uint64Array
- type Uint8Array
- type UintArray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONValue ¶
JSONValue converts something into json. WARNING: This is here temporarily, might be removed in the future, use `JSON` instead.
Types ¶
type Float32Array ¶
type Float32Array []float32
Float32Array represents a one-dimensional array of the PostgreSQL real type.
func (*Float32Array) Scan ¶
func (a *Float32Array) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type Int16Array ¶
type Int16Array []int16
Int16Array represents a one-dimensional array of the PostgreSQL integer type.
func (*Int16Array) Scan ¶
func (a *Int16Array) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type Int32Array ¶
type Int32Array []int32
Int32Array represents a one-dimensional array of the PostgreSQL integer type.
func (*Int32Array) Scan ¶
func (a *Int32Array) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type Int8Array ¶
type Int8Array []int8
Int8Array represents a one-dimensional array of the PostgreSQL integer type.
type IntArray ¶
type IntArray []int
IntArray represents a one-dimensional array of the PostgreSQL integer type.
type SQLType ¶
SQLType is the common interface a type has to fulfill to be considered a SQL type.
func JSON ¶
func JSON(v interface{}) SQLType
JSON makes sure the given value is converted to and scanned from SQL as a JSON. Note that this uses the standard json.Unmarshal and json.Marshal and it relies on reflection. To speed up the encoding/decoding you can implement interfaces json.Marshaller and json.Unmarshaller for your type with, for example, ffjson.
func Slice ¶
func Slice(v interface{}) SQLType
Slice wraps a slice value so it can be scanned from and converted to PostgreSQL arrays. The following values can be used with this function:
- slices of basic types
- slices of *url.URL and url.URL
- slices of types that implement sql.Scanner and driver.Valuer (take into account that these make use of reflection for scan/value)
NOTE: Keep in mind to always use the following types in the database schema to keep it in sync with the values allowed in Go.
- int64: bigint
- uint64: numeric(20)
- int: bigint
- uint: numeric(20)
- int32: integer
- uint32: bigint
- int16: smallint
- uint16: integer
- int8: smallint
- uint8: smallint
Use them with care.
type Uint16Array ¶
type Uint16Array []uint16
Uint16Array represents a one-dimensional array of the PostgreSQL unsigned integer type.
func (*Uint16Array) Scan ¶
func (a *Uint16Array) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type Uint32Array ¶
type Uint32Array []uint32
Uint32Array represents a one-dimensional array of the PostgreSQL unsigned integer type.
func (*Uint32Array) Scan ¶
func (a *Uint32Array) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type Uint64Array ¶
type Uint64Array []uint64
Uint64Array represents a one-dimensional array of the PostgreSQL unsigned bigint type.
func (*Uint64Array) Scan ¶
func (a *Uint64Array) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type Uint8Array ¶
type Uint8Array []uint8
Uint8Array represents a one-dimensional array of the PostgreSQL unsigned integer type.
func (*Uint8Array) Scan ¶
func (a *Uint8Array) Scan(src interface{}) error
Scan implements the sql.Scanner interface.