qm

package
v3.0.0-rc4+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2018 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(q *queries.Query, mods ...QueryMod)

Apply the query mods to the Query object

Types

type QueryMod

type QueryMod func(q *queries.Query)

QueryMod to modify the query object

func And

func And(clause string, args ...interface{}) QueryMod

And allows you to specify a where clause separated by an AND for your statement And is a duplicate of the Where function, but allows for more natural looking query mod chains, for example: (Where("a=?"), And("b=?"), Or("c=?")))

func AndIn

func AndIn(clause string, args ...interface{}) QueryMod

AndIn allows you to specify a "x IN (set)" clause separated by an AndIn for your where statement. AndIn is a duplicate of the WhereIn function, but allows for more natural looking query mod chains, for example: (WhereIn("column1 in ?"), AndIn("column2 in ?"), OrIn("column3 in ?"))

func For

func For(clause string) QueryMod

For inserts a concurrency locking clause at the end of your statement

func From

func From(from string) QueryMod

From allows to specify the table for your statement

func GroupBy

func GroupBy(clause string) QueryMod

GroupBy allows you to specify a group by clause for your statement

func Having

func Having(clause string, args ...interface{}) QueryMod

Having allows you to specify a having clause for your statement

func InnerJoin

func InnerJoin(clause string, args ...interface{}) QueryMod

InnerJoin on another table

func Limit

func Limit(limit int) QueryMod

Limit the number of returned rows

func Load

func Load(relationship string, mods ...QueryMod) QueryMod

Load allows you to specify foreign key relationships to eager load for your query. Passed in relationships need to be in the format MyThing or MyThings. Relationship name plurality is important, if your relationship is singular, you need to specify the singular form and vice versa.

In the following example we see how to eager load a users's videos and the video's tags comments, and publisher during a query to find users.

models.Users(qm.Load("Videos.Tags"))

In order to filter better on the query for the relationships you can additionally supply query mods.

models.Users(qm.Load("Videos.Tags", Where("deleted = ?", isDeleted)))

Keep in mind the above only sets the query mods for the query on the last specified relationship. In this case, only Tags will get the query mod. If you want to do intermediate relationships with query mods you must specify them separately:

models.Users(
  qm.Load("Videos", Where("deleted = false"))
  qm.Load("Videos.Tags", Where("deleted = ?", isDeleted))
)

func Offset

func Offset(offset int) QueryMod

Offset into the results

func Or

func Or(clause string, args ...interface{}) QueryMod

Or allows you to specify a where clause separated by an OR for your statement

func OrIn

func OrIn(clause string, args ...interface{}) QueryMod

OrIn allows you to specify an IN clause separated by an OR for your where statement

func OrderBy

func OrderBy(clause string) QueryMod

OrderBy allows you to specify a order by clause for your statement

func SQL

func SQL(sql string, args ...interface{}) QueryMod

SQL allows you to execute a plain SQL statement

func Select

func Select(columns ...string) QueryMod

Select specific columns opposed to all columns

func Where

func Where(clause string, args ...interface{}) QueryMod

Where allows you to specify a where clause for your statement

func WhereIn

func WhereIn(clause string, args ...interface{}) QueryMod

WhereIn allows you to specify a "x IN (set)" clause for your where statement Example clauses: "column in ?", "(column1,column2) in ?"

Jump to

Keyboard shortcuts

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