Documentation ¶
Index ¶
- Constants
- func ScanInt(value interface{}, v *Int) error
- func ScanString(value interface{}, v *String) error
- func UnmarshalInt(b []byte, v *Int) error
- func UnmarshalString(b []byte, v *String) error
- type Int
- type JSON
- type Map
- func (m *Map) Get(key string, def interface{}) interface{}
- func (m *Map) GetString(key string, def string) string
- func (m *Map) Map() map[string]interface{}
- func (m Map) MarshalJSON() ([]byte, error)
- func (m *Map) Scan(src interface{}) error
- func (m *Map) UnmarshalJSON(data []byte) error
- func (m Map) Value() (driver.Value, error)
- type String
Constants ¶
const NullInt = Int(0)
NullInt is our constant for an Int value that will be written as null
const NullString = String("")
NullString is our constant for an String value that will be written as null
Variables ¶
This section is empty.
Functions ¶
func ScanInt ¶
ScanInt is a utility method that can be used to scan a db value and return an Int and error In the case of an error, null or "" values, NullInt is returned
func ScanString ¶
ScanString is a utility method that can be used to scan a db value and return a String and error In the case of an error, null or "" values, NullString is returned
func UnmarshalInt ¶
UnmarshalInt is a utility method that can be used to unmarshal a json value to an Int and error In the case of an error, null or "" values, NullInt is returned
func UnmarshalString ¶
UnmarshalString is a utility method that can be used to unmarshal a json value to a String and error In the case of an error, null or "" values, NullString is returned
Types ¶
type Int ¶
type Int int64
Int is an int that will write as null when it is zero both to databases and json null values when unmashalled or scanned from a DB will result in a 0 value
func (Int) MarshalJSON ¶
MarshalJSON marshals our int to JSON. 0 values will be marshalled as null
func (*Int) UnmarshalJSON ¶
UnmarshalJSON unmarshals our JSON to int. null values will be marshalled to 0
type JSON ¶ added in v1.2.0
type JSON json.RawMessage
JSON is a json.RawMessage that will marshall as null when empty or nil. null and {} values when unmashalled or scanned from a DB will result in a nil value
func (JSON) MarshalJSON ¶ added in v1.2.0
MarshalJSON encodes our JSON to JSON or null
func (*JSON) Scan ¶ added in v1.2.0
Scan implements the Scanner interface for decoding from a database
func (*JSON) UnmarshalJSON ¶ added in v1.2.0
UnmarshalJSON sets our JSON from the passed in JSON
type Map ¶ added in v1.1.1
type Map struct {
// contains filtered or unexported fields
}
Map is a one level deep dictionary that is represented as JSON text in the database. Empty maps will be written as null to the database and to JSON.
func (*Map) GetString ¶ added in v1.1.1
GetString returns the string value with the passed in key, or def if not found or of wrong type
func (Map) MarshalJSON ¶ added in v1.1.1
MarshalJSON encodes our map to JSON
func (*Map) Scan ¶ added in v1.1.1
Scan implements the Scanner interface for decoding from a database
func (*Map) UnmarshalJSON ¶ added in v1.1.1
UnmarshalJSON sets our map from the passed in JSON
type String ¶
type String string
String is string that will write as null when it is "" both to databases and json null values when unmashalled or scanned from a DB will result in a "" value
func (String) MarshalJSON ¶
MarshalJSON marshals our string to JSON. "" values will be marshalled as null
func (*String) UnmarshalJSON ¶
UnmarshalJSON unmarshals our json to a string. null values will be marshalled to ""