sqlxx

package
v0.0.68 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: Apache-2.0 Imports: 4 Imported by: 66

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

This section is empty.

Jump to

Keyboard shortcuts

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