nulls: github.com/gobuffalo/nulls Index | Files

package nulls

import "github.com/gobuffalo/nulls"

Index

Package Files

bool.go byte_slice.go float32.go float64.go int.go int32.go int64.go nulls.go schema.go string.go time.go uint32.go uuid.go version.go

Constants

const Version = "v0.1.0"

Version of nulls

func RegisterWithSchema Uses

func RegisterWithSchema(reg register)

RegisterWithSchema allows for the nulls package to be used with http://www.gorillatoolkit.org/pkg/schema#Converter

type Bool Uses

type Bool struct {
    Bool  bool
    Valid bool
}

Bool replaces sql.NullBool with an implementation that supports proper JSON encoding/decoding.

func NewBool Uses

func NewBool(b bool) Bool

NewBool returns a new, properly instantiated Boll object.

func (Bool) Interface Uses

func (ns Bool) Interface() interface{}

Interface implements the nullable interface. It returns nil if the bool is not valid, otherwise it returns the bool value.

func (Bool) MarshalJSON Uses

func (ns Bool) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*Bool) Scan Uses

func (ns *Bool) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Bool) UnmarshalJSON Uses

func (ns *Bool) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the proper representation of that value. The strings "true" and "t" will be considered "true", "false" and "f" will be treated as "false". All other values will be set to null by Valid = false

func (*Bool) UnmarshalText Uses

func (ns *Bool) UnmarshalText(text []byte) error

UnmarshalText will unmarshal text value into the propert representation of that value.

func (Bool) Value Uses

func (ns Bool) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type ByteSlice Uses

type ByteSlice struct {
    ByteSlice []byte
    Valid     bool // Valid is true if ByteSlice is not NULL
}

ByteSlice adds an implementation for []byte that supports proper JSON encoding/decoding.

func NewByteSlice Uses

func NewByteSlice(b []byte) ByteSlice

NewByteSlice returns a new, properly instantiated ByteSlice object.

func (ByteSlice) Interface Uses

func (ns ByteSlice) Interface() interface{}

Interface implements the nullable interface. It returns nil if the byte slice is not valid, otherwise it returns the byte slice value.

func (ByteSlice) MarshalJSON Uses

func (ns ByteSlice) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*ByteSlice) Scan Uses

func (ns *ByteSlice) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*ByteSlice) UnmarshalJSON Uses

func (ns *ByteSlice) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the propert representation of that value.

func (*ByteSlice) UnmarshalText Uses

func (ns *ByteSlice) UnmarshalText(text []byte) error

UnmarshalText will unmarshal text value into the propert representation of that value.

func (ByteSlice) Value Uses

func (ns ByteSlice) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Float32 Uses

type Float32 struct {
    Float32 float32
    Valid   bool // Valid is true if Float32 is not NULL
}

Float32 adds an implementation for float32 that supports proper JSON encoding/decoding.

func NewFloat32 Uses

func NewFloat32(i float32) Float32

NewFloat32 returns a new, properly instantiated Float32 object.

func (Float32) Interface Uses

func (ns Float32) Interface() interface{}

Interface implements the nullable interface. It returns nil if the float32 is not valid, otherwise it returns the float32 value.

func (Float32) MarshalJSON Uses

func (ns Float32) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*Float32) Scan Uses

func (ns *Float32) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Float32) UnmarshalJSON Uses

func (ns *Float32) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the propert representation of that value.

func (*Float32) UnmarshalText Uses

func (ns *Float32) UnmarshalText(text []byte) error

UnmarshalText will unmarshal text value into the propert representation of that value.

func (Float32) Value Uses

func (ns Float32) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Float64 Uses

type Float64 sql.NullFloat64

Float64 replaces sql.NullFloat64 with an implementation that supports proper JSON encoding/decoding.

func NewFloat64 Uses

func NewFloat64(i float64) Float64

NewFloat64 returns a new, properly instantiated Float64 object.

func (Float64) Interface Uses

func (ns Float64) Interface() interface{}

Interface implements the nullable interface. It returns nil if the float64 is not valid, otherwise it returns the float64 value.

func (Float64) MarshalJSON Uses

func (ns Float64) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*Float64) Scan Uses

func (ns *Float64) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Float64) UnmarshalJSON Uses

func (ns *Float64) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the propert representation of that value.

func (*Float64) UnmarshalText Uses

func (ns *Float64) UnmarshalText(text []byte) error

UnmarshalText will unmarshal text value into the propert representation of that value.

func (Float64) Value Uses

func (ns Float64) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Int Uses

type Int struct {
    Int   int
    Valid bool // Valid is true if Int is not NULL
}

Int adds an implementation for int that supports proper JSON encoding/decoding.

func NewInt Uses

func NewInt(i int) Int

NewInt returns a new, properly instantiated Int object.

func (Int) Interface Uses

func (ns Int) Interface() interface{}

Interface implements the nullable interface. It returns nil if the int is not valid, otherwise it returns the int value.

func (Int) MarshalJSON Uses

func (ns Int) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*Int) Scan Uses

func (ns *Int) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Int) UnmarshalJSON Uses

func (ns *Int) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the propert representation of that value.

func (*Int) UnmarshalText Uses

func (ns *Int) UnmarshalText(text []byte) error

UnmarshalText will unmarshal text value into the propert representation of that value.

func (Int) Value Uses

func (ns Int) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Int32 Uses

type Int32 struct {
    Int32 int32
    Valid bool // Valid is true if Int32 is not NULL
}

Int32 adds an implementation for int32 that supports proper JSON encoding/decoding.

func NewInt32 Uses

func NewInt32(i int32) Int32

NewInt32 returns a new, properly instantiated Int object.

func (Int32) Interface Uses

func (ns Int32) Interface() interface{}

Interface implements the nullable interface. It returns nil if the int32 is not valid, otherwise it returns the int32 value.

func (Int32) MarshalJSON Uses

func (ns Int32) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*Int32) Scan Uses

func (ns *Int32) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Int32) UnmarshalJSON Uses

func (ns *Int32) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the propert representation of that value.

func (*Int32) UnmarshalText Uses

func (ns *Int32) UnmarshalText(text []byte) error

UnmarshalText will unmarshal text value into the propert representation of that value.

func (Int32) Value Uses

func (ns Int32) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Int64 Uses

type Int64 sql.NullInt64

Int64 replaces sql.Int64 with an implementation that supports proper JSON encoding/decoding.

func NewInt64 Uses

func NewInt64(i int64) Int64

NewInt64 returns a new, properly instantiated Int64 object.

func (Int64) Interface Uses

func (ns Int64) Interface() interface{}

Interface implements the nullable interface. It returns nil if the int64 is not valid, otherwise it returns the int64 value.

func (Int64) MarshalJSON Uses

func (ns Int64) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*Int64) Scan Uses

func (ns *Int64) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Int64) UnmarshalJSON Uses

func (ns *Int64) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the propert representation of that value.

func (*Int64) UnmarshalText Uses

func (ns *Int64) UnmarshalText(text []byte) error

UnmarshalText will unmarshal text value into the propert representation of that value.

func (Int64) Value Uses

func (ns Int64) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Nulls Uses

type Nulls struct {
    Value interface{}
}

Nulls a generic nulls type. something that implements nullable interface. can be any of nulls.Int, nulls.uuid.UUID nulls.String, etc.

func New Uses

func New(i interface{}) *Nulls

New returns a wrapper called nulls for the interface passed as a param.

func (*Nulls) Interface Uses

func (nulls *Nulls) Interface() interface{}

Interface calls Interface function for value.

func (*Nulls) Parse Uses

func (nulls *Nulls) Parse(value interface{}) interface{}

Parse parses the specified value to the corresponding nullable type. value is one of the inner value hold by a nullable type. i.e int, string, uuid.UUID etc.

type String Uses

type String sql.NullString

String replaces sql.NullString with an implementation that supports proper JSON encoding/decoding.

func NewString Uses

func NewString(s string) String

NewString returns a new, properly instantiated String object.

func (String) Interface Uses

func (ns String) Interface() interface{}

Interface implements the nullable interface. It returns nil if the string is not valid, otherwise it returns the string value.

func (String) MarshalJSON Uses

func (ns String) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*String) Scan Uses

func (ns *String) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*String) UnmarshalJSON Uses

func (ns *String) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the propert representation of that value.

func (*String) UnmarshalText Uses

func (ns *String) UnmarshalText(text []byte) error

UnmarshalText will unmarshal text value into the propert representation of that value.

func (String) Value Uses

func (ns String) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Time Uses

type Time struct {
    Time  time.Time
    Valid bool // Valid is true if Time is not NULL
}

Time replaces sql.NullTime with an implementation that supports proper JSON encoding/decoding.

func NewTime Uses

func NewTime(t time.Time) Time

NewTime returns a new, properly instantiated Time object.

func (Time) Interface Uses

func (ns Time) Interface() interface{}

Interface implements the nullable interface. It returns nil if the Time is not valid, otherwise it returns the Time value.

func (Time) MarshalJSON Uses

func (ns Time) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*Time) Scan Uses

func (ns *Time) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Time) UnmarshalJSON Uses

func (ns *Time) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the propert representation of that value.

func (*Time) UnmarshalText Uses

func (ns *Time) UnmarshalText(text []byte) error

UnmarshalText will unmarshal text value into the propert representation of that value.

func (Time) Value Uses

func (ns Time) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type UInt32 Uses

type UInt32 struct {
    UInt32 uint32
    Valid  bool // Valid is true if Int is not NULL
}

UInt32 adds an implementation for int that supports proper JSON encoding/decoding.

func NewUInt32 Uses

func NewUInt32(i uint32) UInt32

NewUInt32 returns a new, properly instantiated Int object.

func (UInt32) Interface Uses

func (ns UInt32) Interface() interface{}

Interface implements the nullable interface. It returns nil if the uint32 is not valid, otherwise it returns the uint32 value.

func (UInt32) MarshalJSON Uses

func (ns UInt32) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*UInt32) Scan Uses

func (ns *UInt32) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*UInt32) UnmarshalJSON Uses

func (ns *UInt32) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the propert representation of that value.

func (*UInt32) UnmarshalText Uses

func (ns *UInt32) UnmarshalText(text []byte) error

UnmarshalText will unmarshal text value into the propert representation of that value.

func (UInt32) Value Uses

func (ns UInt32) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type UUID Uses

type UUID struct {
    UUID  uuid.UUID
    Valid bool
}

UUID can be used with the standard sql package to represent a UUID value that can be NULL in the database

func NewUUID Uses

func NewUUID(u uuid.UUID) UUID

NewUUID returns a new, properly instantiated UUID object.

func (UUID) Interface Uses

func (u UUID) Interface() interface{}

Interface implements the nullable interface. It returns nil if the UUID is not valid, otherwise it returns the UUID value.

func (UUID) MarshalJSON Uses

func (u UUID) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*UUID) Scan Uses

func (u *UUID) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (*UUID) UnmarshalJSON Uses

func (u *UUID) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the propert representation of that value.

func (*UUID) UnmarshalText Uses

func (u *UUID) UnmarshalText(text []byte) error

UnmarshalText will unmarshal text value into the propert representation of that value.

func (UUID) Value Uses

func (u UUID) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

Package nulls imports 9 packages (graph) and is imported by 6 packages. Updated 2019-06-25. Refresh now. Tools for package owners.