types

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONValue

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

JSONValue converts something into json. WARNING: This is here temporarily, might be removed in the future, use `JSON` instead.

func Nullable added in v0.12.0

func Nullable(typ interface{}) interface{}

Nullable gives the ability to scan nil values to the given type only if they implement sql.Scanner.

func ScanJSON

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

ScanJSON scans json v into dst. 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.

func (Float32Array) Value

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

Value implements the driver.Valuer 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.

func (Int16Array) Value

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

Value implements the driver.Valuer 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.

func (Int32Array) Value

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

Value implements the driver.Valuer interface.

type Int8Array

type Int8Array []int8

Int8Array represents a one-dimensional array of the PostgreSQL integer type.

func (*Int8Array) Scan

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

Scan implements the sql.Scanner interface.

func (Int8Array) Value

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

Value implements the driver.Valuer interface.

type IntArray

type IntArray []int

IntArray represents a one-dimensional array of the PostgreSQL integer type.

func (*IntArray) Scan

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

Scan implements the sql.Scanner interface.

func (IntArray) Value

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

Value implements the driver.Valuer interface.

type SQLType

type SQLType interface {
	sql.Scanner
	driver.Valuer
}

SQLType is the common interface a type has to fulfill to be considered a SQL type.

func Array

func Array(v interface{}, size int) SQLType

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 URL

type URL url.URL

URL is a wrapper of url.URL that implements SQLType interface.

func (*URL) Scan

func (u *URL) Scan(v interface{}) error

func (URL) Value

func (u URL) Value() (interface{}, error)

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.

func (Uint16Array) Value

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

Value implements the driver.Valuer 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.

func (Uint32Array) Value

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

Value implements the driver.Valuer 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.

func (Uint64Array) Value

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

Value implements the driver.Valuer 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.

func (Uint8Array) Value

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

Value implements the driver.Valuer interface.

type UintArray

type UintArray []uint

UintArray represents a one-dimensional array of the PostgreSQL unsigned integer type.

func (*UintArray) Scan

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

Scan implements the sql.Scanner interface.

func (UintArray) Value

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

Value implements the driver.Valuer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL