Documentation
¶
Overview ¶
Package types provides some useful types which implement the `sql.Scanner` and `driver.Valuer` interfaces, suitable for use as scan and value targets with database/sql.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var EmptyJSON = JSONText("{}")
EmptyJSON is a JSON without key-value pairs.
var ErrBadBitBoolSource = errors.New("bad []byte type assertion")
ErrBadBitBoolSource is returned when BitBool.Scan the type assertion fails
var ErrIncopatibleTypeForGzipText = errors.New("incompatible type for GzippedText")
ErrIncopatibleTypeForGzipText is returned when the type passed to GzippedText.Scan is incompatible
Functions ¶
This section is empty.
Types ¶
type BitBool ¶
type BitBool bool
BitBool is an implementation of a bool for the MySQL type BIT(1). This type allows you to avoid wasting an entire byte for MySQL's boolean type TINYINT.
type GzippedText ¶
type GzippedText struct {
// contains filtered or unexported fields
}
GzippedText is a []byte which transparently gzips data being submitted to a database and ungzips data being Scanned from a database.
func NewGzippedText ¶
func NewGzippedText(content ...byte) *GzippedText
func (*GzippedText) Bytes ¶
func (g *GzippedText) Bytes() []byte
Bytes returns the gzipped text bytes
func (*GzippedText) Scan ¶
func (g *GzippedText) Scan(src any) error
Scan implements the sql.Scanner interface, ungzipping the value coming off the wire and storing the raw result in the GzippedText.
type JSONText ¶
type JSONText json.RawMessage
JSONText is a json.RawMessage, which is a []byte underneath. Value() validates the json format in the source, and returns an error if the json is not valid. Scan does no validation. JSONText additionally implements `Unmarshal`, which unmarshals the json within to an any
func NewJSONText ¶
NewJSONText returns a new JSONText with the given data.
func (JSONText) MarshalJSON ¶
MarshalJSON returns the *j as the JSON encoding of j.
func (*JSONText) UnmarshalJSON ¶
UnmarshalJSON sets *j to a copy of data
type NullJSONText ¶
NullJSONText represents a JSONText that may be null. NullJSONText implements the scanner interface so it can be used as a scan destination, similar to NullString.
func (*NullJSONText) Scan ¶
func (n *NullJSONText) Scan(value any) error
Scan implements the Scanner interface.