stquery

package
v0.0.0-...-f3d8a94 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Statement

func Statement(dest interface{}, template string) (query string)

Statement returns an SQL query statement that selects columns based on the names of the fields in dest, which must be a pointer to a struct. If a field has the "stquery" tag, its value holds the name that will be used.

The given template string must contain an occurrence of "$fields", which will be replaced with a comma-separated list of the names.

Types

type Getter

type Getter struct {
	// contains filtered or unexported fields
}

Getter represents a value that can fetch itself by calling Scan on an underlying Scanner.

func NewGetter

func NewGetter(dest interface{}, scan Scanner) *Getter

NewGetter returns a Getter that uses the given scanner to read values into the fields in dest, which must be a pointer to a struct.

func (*Getter) Get

func (g *Getter) Get() error

Get gets a set of values by calling Scan, and stores them in fields of the destination value.

type Scanner

type Scanner interface {
	Scan(dest ...interface{}) error
}

Scanner represents a database row that can scan itself.

Jump to

Keyboard shortcuts

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