Documentation ¶
Index ¶
- func NullBoolFrom(v bool) sql.NullBool
- func NullFloat64From(v float64) sql.NullFloat64
- func NullInt64From(v int64) sql.NullInt64
- func NullStringFrom(v string) sql.NullString
- type BoolSlice
- type CompactJSONStr
- func (js CompactJSONStr) MarshalJSON() ([]byte, error)
- func (js *CompactJSONStr) Scan(src interface{}) error
- func (js CompactJSONStr) String() string
- func (js *CompactJSONStr) Unmarshal(v interface{}) error
- func (js *CompactJSONStr) UnmarshalJSON(data []byte) error
- func (js CompactJSONStr) Value() (driver.Value, error)
- type Float64Slice
- type Int64Slice
- type JSONStr
- type Map
- type NullBool
- type NullBytes
- type NullCompactJSONStr
- type NullFloat64
- type NullInt64
- type NullJSONStr
- type NullString
- type NullTime
- type StrSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NullBoolFrom ¶
NullBoolFrom creates a valid NullBool Deprecated: will be renamed in future version, use `ToNullBool`
func NullFloat64From ¶
func NullFloat64From(v float64) sql.NullFloat64
NullFloat64From creates a valid NullFloat64 Deprecated: will be renamed in future version, use `ToNullFloat64`
func NullInt64From ¶
NullInt64From creates a valid NullInt64 Deprecated: will be renamed in future version, use `ToNullInt64`
func NullStringFrom ¶
func NullStringFrom(v string) sql.NullString
NullStringFrom creates a valid NullString Deprecated: will be renamed in future version, use `ToNullString`
Types ¶
type BoolSlice ¶
type BoolSlice []bool
BoolSlice makes easy to handle JSON encoded bool lists stored at database's text fields(like VARCHAR,CHAR,TEXT) and blob fields
type CompactJSONStr ¶
type CompactJSONStr json.RawMessage
CompactJSONStr is same as JSONStr except, whitespaces are remove from JSON formatted data while saving to database. It is useless if data is hold in database specific json typed field(like PostgreSQL's JSONB field). NullCompactJSONStr is nullable version of CompactJSONStr.
CompactJSONStr is `json.RawMessage` (`[]byte`) type, adding `Value()` and `Scan()` methods for db access and `MarshalJSON`, `UnmarshalJSON` for json serializing.
This type make use of DB binary or string fields like a JSON container. DB field type can be text types like CHAR, STRING, CHARACTER VARYING, TEXT or binary types like JSONB, BYTEA, BLOB...
JSON data is hold as "compacted" mode in database.
For performance binary db field use is advised.
func (CompactJSONStr) MarshalJSON ¶
func (js CompactJSONStr) MarshalJSON() ([]byte, error)
MarshalJSON returns JSON encoding
func (*CompactJSONStr) Scan ¶
func (js *CompactJSONStr) Scan(src interface{}) error
Scan stores the value as CompactJSONStr. Value can be string, []byte or or nil.
func (*CompactJSONStr) Unmarshal ¶
func (js *CompactJSONStr) Unmarshal(v interface{}) error
Unmarshal unmarshal's using json.Unmarshal.
func (*CompactJSONStr) UnmarshalJSON ¶
func (js *CompactJSONStr) UnmarshalJSON(data []byte) error
UnmarshalJSON sets copy of data to instance
type Float64Slice ¶
type Float64Slice []float64
Float64Slice makes easy to handle JSON encoded float64 lists stored at database's text fields(like VARCHAR,CHAR,TEXT) and blob fields
func (*Float64Slice) Scan ¶
func (ss *Float64Slice) Scan(src interface{}) error
Scan stores the value as Float64Slice. Value can be string, []byte or or nil.
type Int64Slice ¶
type Int64Slice []int64
Int64Slice makes easy to handle JSON encoded int64 lists stored at database's text fields(like VARCHAR,CHAR,TEXT) and blob fields
func (*Int64Slice) Scan ¶
func (ss *Int64Slice) Scan(src interface{}) error
Scan stores the value as Int64Slice. Value can be string, []byte or or nil.
type JSONStr ¶
type JSONStr json.RawMessage
JSONStr makes easy to handle JSON data at database's text fields(like VARCHAR,CHAR,TEXT) and blob fields
func (JSONStr) MarshalJSON ¶
MarshalJSON returns JSON encoding
func (*JSONStr) UnmarshalJSON ¶
UnmarshalJSON sets copy of data to instance
type Map ¶ added in v1.0.9
type Map map[string]interface{}
Map makes easy to handle JSON encoded map stored at database's text fields(like VARCHAR,CHAR,TEXT) and blob fields
type NullBool ¶
NullBool is a type that can be null or a bool, wrapped for JSON encoding/decoding
func (NullBool) MarshalJSON ¶
MarshalJSON serializes a NullBool to JSON
func (*NullBool) UnmarshalJSON ¶
UnmarshalJSON parses NullBool from JSON
type NullBytes ¶
NullBytes can be an []byte or a null value.
func NullBytesFrom ¶
NullBytesFrom creates a valid NullBytes Deprecated: will be renamed in future version, use `ToNullBytes`
type NullCompactJSONStr ¶
type NullCompactJSONStr struct { CompactJSONStr Valid bool // Valid is true if CompactJSONStr is not NULL }
NullCompactJSONStr can be an CompactJSONStr or a null value. Can be used like `JSONStr`
func NullCompactJSONStrFrom ¶
func NullCompactJSONStrFrom(dst []byte) NullCompactJSONStr
NullCompactJSONStrFrom creates a valid NullCompactJSONStr Deprecated: will be renamed in future version, use `ToNullCompactJSONStr`
func ToNullCompactJSONStr ¶
func ToNullCompactJSONStr(dst []byte) NullCompactJSONStr
ToNullCompactJSONStr creates a valid NullCompactJSONStr
func (*NullCompactJSONStr) Scan ¶
func (n *NullCompactJSONStr) Scan(value interface{}) error
Scan implements the Scanner interface.
type NullFloat64 ¶
type NullFloat64 struct {
sql.NullFloat64
}
NullFloat64 is a type that can be null or a float64, wrapped for JSON encoding/decoding
func ToNullFloat64 ¶
func ToNullFloat64(v float64) NullFloat64
ToNullFloat64 creates a valid NullFloat64
func (NullFloat64) MarshalJSON ¶
func (n NullFloat64) MarshalJSON() ([]byte, error)
MarshalJSON serializes a NullFloat64 to JSON
func (*NullFloat64) UnmarshalJSON ¶
func (n *NullFloat64) UnmarshalJSON(b []byte) error
UnmarshalJSON parses NullFloat64 from JSON
type NullInt64 ¶
NullInt64 is a type that can be null or an int, wrapped for JSON encoding/decoding
func (NullInt64) MarshalJSON ¶
MarshalJSON NullInt64 to JSON
func (*NullInt64) UnmarshalJSON ¶
UnmarshalJSON parses NullInt64 from JSON
type NullJSONStr ¶
NullJSONStr can be an JSONStr or a null value. Can be used like `sql.NullSting`
func NullJSONStrFrom ¶
func NullJSONStrFrom(dst []byte) NullJSONStr
NullJSONStrFrom creates a valid NullJSONStr Deprecated: will be renamed in future version, use `ToNullJSONStr`
func ToNullJSONStr ¶
func ToNullJSONStr(dst []byte) NullJSONStr
ToNullJSONStr creates a valid NullJSONStr
func (*NullJSONStr) Scan ¶
func (n *NullJSONStr) Scan(value interface{}) error
Scan implements the Scanner interface.
type NullString ¶
type NullString struct {
sql.NullString
}
NullString is a type that can be null or a string, wrapped for JSON encoding/decoding
func (NullString) MarshalJSON ¶
func (n NullString) MarshalJSON() ([]byte, error)
MarshalJSON serializes a NullString to JSON
func (*NullString) UnmarshalJSON ¶
func (n *NullString) UnmarshalJSON(b []byte) error
UnmarshalJSON parses NullString from JSON
type NullTime ¶
NullTime is a type that can be null or a time
func NullTimeFrom ¶
NullTimeFrom creates a valid NullTime Deprecated: will be renamed in future version, use `ToNullTime`
func (NullTime) MarshalJSON ¶
MarshalJSON serializes a NullTime to JSON.
func (*NullTime) UnmarshalJSON ¶
UnmarshalJSON deserializes a NullTime from JSON.