query

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

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

Go to latest
Published: Sep 17, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Placeholder string = "?"

Placeholder used for sql arguments

Variables

This section is empty.

Functions

This section is empty.

Types

type And

type And struct{}

And represents an AND comparison query part

func (And) ToSQL

func (and And) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of an AND query part along with its arguments (if any)

type BaseDomainObject

type BaseDomainObject struct {
	FieldList map[string]*DomainObjectField `json:"-"`
	TableName string                        `json:"-"`
}

BaseDomainObject is the base object inherited by all domain objects Note: These fields include json tags for omission when the inheriting object attempts to marshal (e.g. for a JSON response from an API)

func (*BaseDomainObject) GetFields

func (b *BaseDomainObject) GetFields() map[string]*DomainObjectField

GetFields returns a map of the fields in the domain object

func (*BaseDomainObject) GetFieldsOrdered

func (b *BaseDomainObject) GetFieldsOrdered() []*DomainObjectField

GetFieldsOrdered returns a slice of fields in the domain object, ordered by their ordinal

func (*BaseDomainObject) GetName

func (b *BaseDomainObject) GetName() string

GetName returns the name of the domain object

type Between

type Between map[string][]interface{}

Between represents a BETWEEN query part

func (Between) ToSQL

func (between Between) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of a BETWEEN query part along with its arguments (if any)

type CloseParenthesis

type CloseParenthesis struct{}

CloseParenthesis represents a close parenthesis (group end) query part

func (CloseParenthesis) ToSQL

func (closeParenthesis CloseParenthesis) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of an Close Parenthesis (group end) query part

type CountQuery

type CountQuery struct {
	Object DomainObject
	// contains filtered or unexported fields
}

CountQuery is the containing struct for functionality to build count statements on domain objects

func Count

func Count() *CountQuery

Count initiates a count statement Count(DomainObject)

func (*CountQuery) And

func (s *CountQuery) And(queryParts ...IQueryPart) *CountQuery

And adds an "and group" to the query

func (*CountQuery) Or

func (s *CountQuery) Or(queryParts ...IQueryPart) *CountQuery

Or adds an "or group" to the select query

func (*CountQuery) ToSQL

func (s *CountQuery) ToSQL() (sql string, args []interface{})

ToSQL builds a sql select statement

func (*CountQuery) Where

func (s *CountQuery) Where(queryParts ...IQueryPart) *CountQuery

Where is sugar for the And(queryParts...) method

type DeleteQuery

type DeleteQuery struct {
	Object DomainObject
	// contains filtered or unexported fields
}

DeleteQuery is the containing struct for functionality to build select statements on domain objects

func Delete

func Delete() *DeleteQuery

Delete initiates a select statement

func (*DeleteQuery) And

func (s *DeleteQuery) And(queryParts ...IQueryPart) *DeleteQuery

And adds an "and group" to the query

func (*DeleteQuery) Limit

func (s *DeleteQuery) Limit(count int) *DeleteQuery

Limit adds a limit clause to the sql statement

func (*DeleteQuery) Or

func (s *DeleteQuery) Or(queryParts ...IQueryPart) *DeleteQuery

Or adds an "or group" to the select query

func (*DeleteQuery) ToSQL

func (s *DeleteQuery) ToSQL() (sql string, args []interface{})

ToSQL builds a sql select statement

func (*DeleteQuery) Where

func (s *DeleteQuery) Where(queryParts ...IQueryPart) *DeleteQuery

Where is sugar for the And(queryParts...) method

type Distinct

type Distinct struct{}

Distinct represents a DISTINCT clause query part

func (Distinct) ToSQL

func (distinct Distinct) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of a DISTINCT clause

type DomainObject

type DomainObject interface {
	GetFields() map[string]*DomainObjectField
	GetFieldsOrdered() []*DomainObjectField
	GetName() string
	Build()
}

DomainObject is an interface that outlines functionality for every domain object

type DomainObjectField

type DomainObjectField struct {
	Name         string
	Type         string
	IsPrimaryKey bool
	IsNull       bool
	Ordinal      int
}

DomainObjectField is meta data about a field in a domain object

type Equals

type Equals map[string]interface{}

Equals represents an equals comparison query part

func (Equals) ToSQL

func (equals Equals) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of an equals query part along with its arguments (if any)

type FieldList

type FieldList []*DomainObjectField

FieldList is a slice of fields in a domain object

func (FieldList) Len

func (fieldList FieldList) Len() int

func (FieldList) Less

func (fieldList FieldList) Less(i, j int) bool

Less is part of sort.Interface. We use count as the value to sort by

func (FieldList) Swap

func (fieldList FieldList) Swap(i, j int)

Swap is part of sort.Interface.

type GreaterThan

type GreaterThan map[string]interface{}

GreaterThan represents a greater than comparison query part

func (GreaterThan) ToSQL

func (greaterThan GreaterThan) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of a greater than query part along with its arguments (if any)

type GreaterThanOrEqual

type GreaterThanOrEqual map[string]interface{}

GreaterThanOrEqual represents a greater than or equal comparison query part

func (GreaterThanOrEqual) ToSQL

func (greaterThanOrEqual GreaterThanOrEqual) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of a greater than or equal query part along with its arguments (if any)

type IQueryPart

type IQueryPart interface {
	ToSQL() (sql string, args []interface{})
}

IQueryPart describes the functionality for a query part

type In

type In map[string][]interface{}

In represents an IN comparison query part

func (In) ToSQL

func (in In) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of an IN query part along with its arguments (if any)

type InsertQuery

type InsertQuery struct {
	Object DomainObject
	// contains filtered or unexported fields
}

InsertQuery is the containing struct for functionality to build select statements on domain objects

func Insert

func Insert() *InsertQuery

Insert initiates an update statement

func (*InsertQuery) ToSQL

func (s *InsertQuery) ToSQL() (sql string, args []interface{})

ToSQL builds a sql select statement

func (*InsertQuery) Value

func (s *InsertQuery) Value(fieldName string, value interface{}) *InsertQuery

Value adds a value part for the fields to be inserted

type LessThan

type LessThan map[string]interface{}

LessThan represents a less than comparison query part

func (LessThan) ToSQL

func (lessThan LessThan) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of a less than query part along with its arguments (if any)

type LessThanOrEqual

type LessThanOrEqual map[string]interface{}

LessThanOrEqual represents a less than or equal comparison query part

func (LessThanOrEqual) ToSQL

func (lessThanOrEqual LessThanOrEqual) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of a less than or equal query part along with its arguments (if any)

type Limit

type Limit []int

Limit represents a LIMIT clause query part

func (Limit) ToSQL

func (limit Limit) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of a LIMIT clause, along with its arguments

type LimitSimple

type LimitSimple int

LimitSimple is a single integer limit

func (LimitSimple) ToSQL

func (dl LimitSimple) ToSQL() (sql string, args []interface{})

ToSQL returns the SQL representation of a LIMIT clause, along with its arguments

type NotBetween

type NotBetween map[string][]interface{}

NotBetween represents a NOT BETWEEN query part

func (NotBetween) ToSQL

func (notBetween NotBetween) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of a NOT BETWEEN query part along with its arguments (if any)

type NotEquals

type NotEquals map[string]interface{}

NotEquals represents a not equals comparison query part

func (NotEquals) ToSQL

func (equals NotEquals) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of a not equals query part along with its arguments (if any)

type NotIn

type NotIn map[string][]interface{}

NotIn represents a NOT IN comparison query part

func (NotIn) ToSQL

func (notIn NotIn) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of a NOT IN query part along with its arguments (if any)

type OpenParenthesis

type OpenParenthesis struct{}

OpenParenthesis represents an open parenthesis (group start) query part

func (OpenParenthesis) ToSQL

func (openParenthesis OpenParenthesis) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of an Open Parenthesis (group start) query part

type Or

type Or struct{}

Or represents an OR comparison query part

func (Or) ToSQL

func (or Or) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of an OR query part along with its arguments (if any)

type OrderBy

type OrderBy struct {
	Field string
	Dir   OrderByDir
}

OrderBy represents an ORDER BY sql clause

func (OrderBy) ToSQL

func (orderBy OrderBy) ToSQL() (sql string, args []interface{})

ToSQL returns the sql representation of an ORDER BY clause

type OrderByDir

type OrderByDir string

OrderByDir is a type containing the order by string for ORDER BY sql clauses

const (
	ASC  OrderByDir = "ASC"
	DESC OrderByDir = "DESC"
)

Directional constants

type SelectQuery

type SelectQuery struct {
	Object DomainObject
	// contains filtered or unexported fields
}

SelectQuery is the containing struct for functionality to build select statements on domain objects

func Select

func Select() *SelectQuery

Select initiates a select statement Select(DomainObject)

func (*SelectQuery) And

func (s *SelectQuery) And(queryParts ...IQueryPart) *SelectQuery

And adds an "and group" to the query

func (*SelectQuery) Distinct

func (s *SelectQuery) Distinct() *SelectQuery

Distinct sets a flag indicating that the SELECT statement will start with a DISTINCT clause

func (*SelectQuery) Limit

func (s *SelectQuery) Limit(offset int, count int) *SelectQuery

Limit adds a limit clause to the sql statement

func (*SelectQuery) Or

func (s *SelectQuery) Or(queryParts ...IQueryPart) *SelectQuery

Or adds an "or group" to the select query

func (*SelectQuery) OrderBy

func (s *SelectQuery) OrderBy(fieldName string, orderByDir OrderByDir) *SelectQuery

OrderBy adds an ORDER BY clause to the sql statement

func (*SelectQuery) ToSQL

func (s *SelectQuery) ToSQL() (sql string, args []interface{})

ToSQL builds a sql select statement

func (*SelectQuery) Where

func (s *SelectQuery) Where(queryParts ...IQueryPart) *SelectQuery

Where is sugar for the And(queryParts...) method

type Set

type Set map[string]interface{}

Set represents a SQL set statement

func (Set) ToSQL

func (set Set) ToSQL() (sql string, args []interface{})

ToSQL returns the SQL representation of a set statement (for update)

type UpdateQuery

type UpdateQuery struct {
	Object DomainObject
	// contains filtered or unexported fields
}

UpdateQuery is the containing struct for functionality to build select statements on domain objects

func Update

func Update(object DomainObject) *UpdateQuery

Update initiates an update statement

func (*UpdateQuery) And

func (s *UpdateQuery) And(queryParts ...IQueryPart) *UpdateQuery

And adds an "and group" to the query

func (*UpdateQuery) Or

func (s *UpdateQuery) Or(queryParts ...IQueryPart) *UpdateQuery

Or adds an "or group" to the select query

func (*UpdateQuery) Set

func (s *UpdateQuery) Set(fieldName string, value interface{}) *UpdateQuery

Set adds a set part to the fields to be updated

func (*UpdateQuery) ToSQL

func (s *UpdateQuery) ToSQL() (sql string, args []interface{})

ToSQL builds a sql select statement

func (*UpdateQuery) Where

func (s *UpdateQuery) Where(queryParts ...IQueryPart) *UpdateQuery

Where is sugar for the And(queryParts...) method

type Values

type Values map[string]interface{}

Values represents the SQL values in an insert statement

func (Values) ToSQL

func (values Values) ToSQL() (sql string, args []interface{})

ToSQL returns the SQL representation of values in an insert statement

Jump to

Keyboard shortcuts

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