query

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Query

type Query struct {
	Pool              *pool.ConnectionPool
	Tables            *qtypes.AliasedTables
	WhereClauses      []qtypes.Queryable
	SelectExpressions []qtypes.SelectExpression
	OptionClauses     []qtypes.QueryOption

	Errors []error
	// contains filtered or unexported fields
}

Query represents an in-flight query that is being built as before actually making the request to the DB. It's purpose is to facillitate a more straightforward interaction with the DB for general purpose usage to avoid having to write direct SQL.

func NewQuery

func NewQuery(pool *pool.ConnectionPool) *Query

NewQuery returns a new Query object attached to a specified pool.

func (Query) Count added in v0.2.1

func (self Query) Count() (count int, err error)

Count makes a call to the db to get the total count that would be returned from the query without any extra QueryOptions (limit, offset, etc).

func (*Query) Join

func (self *Query) Join(objects ...base.Base) *Query

Join adds an object to the query. The joined object should have a Relationship with at least one other object already in the Query.

func (*Query) Limit

func (self *Query) Limit(limit int) *Query

Limit sets a limit to the total returned items for the query.

func (*Query) Offset

func (self *Query) Offset(offset int) *Query

Offset sets an offset from the first item returned in the query.

func (*Query) Order

func (self *Query) Order(order ...qtypes.Queryable) *Query

Order is a convenience wrapper for OrderBy.

func (*Query) OrderBy

func (self *Query) OrderBy(orderStatements ...qtypes.Queryable) *Query

OrderBy adds an ordering to the query. Repeated calls to this function will append to the existing ordering.

func (Query) PrintQuery

func (self Query) PrintQuery() string

PrintQuery prints what query will be made when the query is called.

func (Query) Results

func (self Query) Results() (*qtypes.QueryResults, error)

Results returns the query as a QueryResults object that can be used to read data out of the database in a convenient fashion.

func (*Query) Select

func (self *Query) Select(stmnts ...qtypes.Selectable) *Query

Select sets the selected data for the Query. Repeated calls to this function will Override the existing select clause.

func (Query) String added in v0.2.1

func (self Query) String() string

String wraps the PrintQuery method so that auto-stringing prints the resulting query itself instead of the object.

func (*Query) Where

func (self *Query) Where(clauses ...qtypes.Queryable) *Query

Where creates or appends to the where clause the provided clauses.

Directories

Path Synopsis
Package dot contains mostly a set of shims for dot importing machgo qtypes.
Package dot contains mostly a set of shims for dot importing machgo qtypes.

Jump to

Keyboard shortcuts

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