sqlxx

package
v0.0.215 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2021 License: Apache-2.0 Imports: 11 Imported by: 61

Documentation

Index

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

func JSONValue(src interface{}) (driver.Value, error)

JSONValue is a generic helper for retrieving a SQL JSON-encoded value.

func NamedInsertArguments

func NamedInsertArguments(t interface{}, exclude ...string) (columns string, arguments string)

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

func NamedUpdateArguments(t interface{}, exclude ...string) string

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 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.

func (JSONRawMessage) Value added in v0.0.101

func (m JSONRawMessage) Value() (driver.Value, error)

Value implements the driver Valuer interface.

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.

func (MapStringInterface) Value added in v0.0.101

func (n MapStringInterface) Value() (driver.Value, error)

Value implements the driver Valuer interface.

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-

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.

func (NullJSONRawMessage) Value added in v0.0.112

func (m NullJSONRawMessage) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullString added in v0.0.101

type NullString string

swagger:type string

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.

func (NullString) Value added in v0.0.101

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

Value implements the driver Valuer interface.

type NullTime added in v0.0.101

type NullTime time.Time

NullTime implements sql.NullTime functionality.

func (NullTime) MarshalJSON added in v0.0.102

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

MarshalJSON returns m as the JSON encoding of m.

func (*NullTime) Scan added in v0.0.101

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

Scan implements the Scanner interface.

func (*NullTime) UnmarshalJSON added in v0.0.102

func (ns *NullTime) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *m to a copy of data.

func (NullTime) Value added in v0.0.101

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

Value implements the driver Valuer 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.

func (StringSlicePipeDelimiter) Value added in v0.0.100

Value implements the driver Valuer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL