qbuilder

package module
v0.0.0-...-ca13a99 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2017 License: MIT Imports: 6 Imported by: 0

README

qbuilder

Simple, fast and easy-to-use query builder for jmoiron/sqlx.

Documentation

Overview

Package qbuilder implements a simple, fast and easy-to-use query builder for jmoiron/sqlx.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotStructKind means that the given argument to Select() is not a struct kind.
	ErrNotStructKind = errors.New("argument is not a struct kind")

	// ErrFilterSet means that filters were already set.
	ErrFilterSet = errors.New("filters already set")
)

Functions

This section is empty.

Types

type Formatter

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

Formatter can format strings after a Selection is made.

func (*Formatter) BindVars

func (f *Formatter) BindVars() string

BindVars returns a formatted string containing the bind var placeholders.

func (*Formatter) FieldNames

func (f *Formatter) FieldNames() []string

FieldNames returns the field names.

func (*Formatter) FieldTypes

func (f *Formatter) FieldTypes() []string

FieldTypes returns the field types.

func (*Formatter) Fmt

func (f *Formatter) Fmt(format string) string

Fmt builds a string using format. The following strings are replaced:

$bindvars with the output of BindVars()
$names with the output of Names()
$updates with the output of Updates()
$table with the output of Table()

func (*Formatter) Names

func (f *Formatter) Names() string

Names returns a formatted string containing the names of all the fields.

func (*Formatter) Table

func (f *Formatter) Table() string

Table returns a formatted string containing the fields in table format.

func (*Formatter) Updates

func (f *Formatter) Updates() string

Updates returns a formatted string containing the field updates.

type Selection

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

Selection contains the selected fields and options.

func Select

func Select(s interface{}) *Selection

Select selecs all the fields of s and returns a Selection.

func (*Selection) BindVar

func (s *Selection) BindVar(v string) *Selection

BindVar sets the bind variable placeholder for the formatter.

func (*Selection) Exclude

func (s *Selection) Exclude(fields ...string) *Selection

Exclude excludes fields from Selection.

func (*Selection) FieldSeparator

func (s *Selection) FieldSeparator(v string) *Selection

FieldSeparator sets the field separator for the formatter.

func (*Selection) Fmt

func (s *Selection) Fmt(format string) string

Fmt builds the formatter for this Selection and returns a formatted string.

func (*Selection) Formatter

func (s *Selection) Formatter() *Formatter

Formatter builds and returns the Formatter for this Selection.

func (*Selection) Only

func (s *Selection) Only(fields ...string) *Selection

Only excludes all the fields in the current Selection except fields.

func (*Selection) TagKey

func (s *Selection) TagKey(v string) *Selection

TagKey sets the struct field tag key to use for this Selection.

func (*Selection) TypeTagKey

func (s *Selection) TypeTagKey(v string) *Selection

TypeTagKey sets the struct field tag key for types to use in this Selection.

Jump to

Keyboard shortcuts

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