Documentation ¶
Index ¶
- func JSONScan(dst interface{}, value interface{}) error
- func JSONValue(src interface{}) (driver.Value, error)
- func NamedInsertArguments(t interface{}, exclude ...string) (columns string, arguments string)
- func NamedUpdateArguments(t interface{}, exclude ...string) string
- type Duration
- type Expandable
- type Expandables
- type FalsyNullBool
- type JSONArrayRawMessage
- type JSONRawMessage
- type MapStringInterface
- type NullBool
- type NullDuration
- type NullInt64
- type NullJSONRawMessage
- type NullString
- type NullTime
- type StringSliceJSONFormat
- type StringSlicePipeDelimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONScan ¶ added in v0.0.120
func JSONScan(dst interface{}, value interface{}) error
JSONScan is a generic helper for storing a value as a JSON blob in SQL.
func JSONValue ¶ added in v0.0.120
JSONValue is a generic helper for retrieving a SQL JSON-encoded value.
func NamedInsertArguments ¶
NamedInsertArguments returns columns and arguments for SQL INSERT statements based on a struct's tags. Does not work with nested structs or maps!
type st struct { Foo string `db:"foo"` Bar string `db:"bar,omitempty"` Baz string `db:"-"` Zab string } columns, arguments := NamedInsertArguments(new(st)) query := fmt.Sprintf("INSERT INTO foo (%s) VALUES (%s)", columns, arguments) // INSERT INTO foo (foo, bar) VALUES (:foo, :bar)
func NamedUpdateArguments ¶
NamedUpdateArguments returns columns and arguments for SQL UPDATE statements based on a struct's tags. Does not work with nested structs or maps!
type st struct { Foo string `db:"foo"` Bar string `db:"bar,omitempty"` Baz string `db:"-"` Zab string } query := fmt.Sprintf("UPDATE foo SET %s", NamedUpdateArguments(new(st))) // UPDATE foo SET foo=:foo, bar=:bar
Types ¶
type Duration ¶ added in v0.0.320
Duration represents a JSON and SQL compatible time.Duration. swagger:type string
func (Duration) MarshalJSON ¶ added in v0.0.320
MarshalJSON returns m as the JSON encoding of m.
func (*Duration) UnmarshalJSON ¶ added in v0.0.320
UnmarshalJSON sets *m to a copy of data.
type Expandable ¶ added in v0.0.526
type Expandable string
Expandable controls what fields to expand for projects.
func (Expandable) String ¶ added in v0.0.526
func (e Expandable) String() string
String returns a string representation of the Expandable.
type Expandables ¶ added in v0.0.526
type Expandables []Expandable
Expandables is a list of Expandable values.
func (Expandables) Has ¶ added in v0.0.526
func (e Expandables) Has(search Expandable) bool
Has returns true if the Expandable is in the list.
func (Expandables) ToEager ¶ added in v0.0.526
func (e Expandables) ToEager() []string
ToEager returns the fields used by pop's Eager command.
type FalsyNullBool ¶ added in v0.0.612
FalsyNullBool represents a bool that may be null. It JSON decodes to false if null.
swagger:type bool swagger:model falsyNullBool
func (FalsyNullBool) MarshalJSON ¶ added in v0.0.612
func (ns FalsyNullBool) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (*FalsyNullBool) Scan ¶ added in v0.0.612
func (ns *FalsyNullBool) Scan(value interface{}) error
Scan implements the Scanner interface.
func (*FalsyNullBool) UnmarshalJSON ¶ added in v0.0.612
func (ns *FalsyNullBool) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
type JSONArrayRawMessage ¶ added in v0.0.316
type JSONArrayRawMessage json.RawMessage
JSONArrayRawMessage represents a json.RawMessage which only accepts arrays that works well with JSON, SQL, and Swagger.
func (*JSONArrayRawMessage) Scan ¶ added in v0.0.316
func (m *JSONArrayRawMessage) Scan(value interface{}) error
Scan implements the Scanner interface.
type JSONRawMessage ¶ added in v0.0.101
type JSONRawMessage json.RawMessage
JSONRawMessage represents a json.RawMessage that works well with JSON, SQL, and Swagger.
func (JSONRawMessage) MarshalJSON ¶ added in v0.0.101
func (m JSONRawMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (*JSONRawMessage) Scan ¶ added in v0.0.101
func (m *JSONRawMessage) Scan(value interface{}) error
Scan implements the Scanner interface.
func (*JSONRawMessage) UnmarshalJSON ¶ added in v0.0.101
func (m *JSONRawMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
type MapStringInterface ¶ added in v0.0.101
type MapStringInterface map[string]interface{}
MapStringInterface represents a map[string]interface that works well with JSON, SQL, and Swagger.
func (*MapStringInterface) Scan ¶ added in v0.0.101
func (n *MapStringInterface) Scan(value interface{}) error
Scan implements the Scanner interface.
type NullBool ¶ added in v0.0.315
NullBool represents a bool that may be null. NullBool implements the Scanner interface so swagger:type bool swagger:model nullBool
func (NullBool) MarshalJSON ¶ added in v0.0.315
MarshalJSON returns m as the JSON encoding of m.
func (*NullBool) UnmarshalJSON ¶ added in v0.0.315
UnmarshalJSON sets *m to a copy of data.
type NullDuration ¶ added in v0.0.438
NullDuration represents a nullable JSON and SQL compatible time.Duration.
swagger:type string swagger:model nullDuration
func (NullDuration) MarshalJSON ¶ added in v0.0.438
func (ns NullDuration) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (*NullDuration) Scan ¶ added in v0.0.438
func (ns *NullDuration) Scan(value interface{}) error
Scan implements the Scanner interface.
func (*NullDuration) UnmarshalJSON ¶ added in v0.0.438
func (ns *NullDuration) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
type NullInt64 ¶ added in v0.0.438
NullInt64 represents an int64 that may be null. swagger:model nullInt64
func (NullInt64) MarshalJSON ¶ added in v0.0.438
MarshalJSON returns m as the JSON encoding of m.
func (*NullInt64) UnmarshalJSON ¶ added in v0.0.438
UnmarshalJSON sets *m to a copy of data.
type NullJSONRawMessage ¶ added in v0.0.112
type NullJSONRawMessage json.RawMessage
NullJSONRawMessage represents a json.RawMessage that works well with JSON, SQL, and Swagger and is NULLable-
swagger:model nullJsonRawMessage
func (NullJSONRawMessage) MarshalJSON ¶ added in v0.0.112
func (m NullJSONRawMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (*NullJSONRawMessage) Scan ¶ added in v0.0.112
func (m *NullJSONRawMessage) Scan(value interface{}) error
Scan implements the Scanner interface.
func (*NullJSONRawMessage) UnmarshalJSON ¶ added in v0.0.112
func (m *NullJSONRawMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
type NullString ¶ added in v0.0.101
type NullString string
swagger:type string swagger:model nullString
func (NullString) MarshalJSON ¶ added in v0.0.101
func (ns NullString) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (*NullString) Scan ¶ added in v0.0.101
func (ns *NullString) Scan(value interface{}) error
Scan implements the Scanner interface.
func (NullString) String ¶ added in v0.0.101
func (ns NullString) String() string
String implements the Stringer interface.
func (*NullString) UnmarshalJSON ¶ added in v0.0.101
func (ns *NullString) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
type NullTime ¶ added in v0.0.101
NullTime implements sql.NullTime functionality.
swagger:model nullTime required: false
func (NullTime) MarshalJSON ¶ added in v0.0.102
MarshalJSON returns m as the JSON encoding of m.
func (*NullTime) UnmarshalJSON ¶ added in v0.0.102
UnmarshalJSON sets *m to a copy of data.
type StringSliceJSONFormat ¶ added in v0.0.317
type StringSliceJSONFormat []string
StringSliceJSONFormat represents []string{} which is encoded to/from JSON for SQL storage.
func (*StringSliceJSONFormat) Scan ¶ added in v0.0.317
func (m *StringSliceJSONFormat) Scan(value interface{}) error
Scan implements the Scanner interface.
type StringSlicePipeDelimiter ¶ added in v0.0.100
type StringSlicePipeDelimiter []string
StringSlicePipeDelimiter de/encodes the string slice to/from a SQL string.
func (*StringSlicePipeDelimiter) Scan ¶ added in v0.0.100
func (n *StringSlicePipeDelimiter) Scan(value interface{}) error
Scan implements the Scanner interface.