Documentation
¶
Overview ¶
Package query holds the query builders used in an entity schema.
Index ¶
- type ListByOperations
- type Query
- func (q Query) Contracts(contracts ...entlite.Layer) QueryOperations
- func (q Query) GetContracts() []entlite.Layer
- func (q Query) GetFields() []string
- func (q Query) GetFilters() []filter.Filter
- func (q Query) GetName() string
- func (q Query) GetOrderBy() string
- func (q Query) GetType() Type
- func (q Query) HasCount() bool
- func (q Query) Name(name string) QueryOperations
- func (Query) Query()
- type QueryBuilder
- type QueryOperations
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ListByOperations ¶
type ListByOperations interface {
QueryBuilder
// Count also returns the number of matching rows.
Count() ListByOperations
// OrderBy sorts the result by the given field.
OrderBy(field string) ListByOperations
// Name overrides the auto-generated query/method name
Name(name string) ListByOperations
// Contracts limits the query to the given layers, sqlc or proto.
Contracts(contracts ...entlite.Layer) ListByOperations
}
ListByOperations exposes the modifiers available on a ListBy query.
func ListBy ¶
func ListBy(args ...interface{}) ListByOperations
ListBy lists records with filters. Takes field names, which default to Eq, or Filter values, e.g. ListBy("org_id") or ListBy(filter.Range("age"), filter.Search("name"))
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query holds the state of one query.
func (Query) Contracts ¶ added in v0.0.3
func (q Query) Contracts(contracts ...entlite.Layer) QueryOperations
Contracts limits the query to the given layers, sqlc or proto.
func (Query) GetContracts ¶ added in v0.0.3
GetContracts returns the layers the query belongs to.
func (Query) GetFilters ¶
GetFilters returns the filters of a ListBy query.
func (Query) GetOrderBy ¶
GetOrderBy returns the order by field, or "" when there is none.
func (Query) Name ¶
func (q Query) Name(name string) QueryOperations
Name overrides the auto-generated query/method name
type QueryBuilder ¶
type QueryBuilder interface {
Query()
}
QueryBuilder is implemented by every query.
func DefaultCRUD ¶
func DefaultCRUD() QueryBuilder
DefaultCRUD expands to several queries, so it cannot be named
type QueryOperations ¶
type QueryOperations interface {
QueryBuilder
// Name overrides the auto-generated query/method name
Name(name string) QueryOperations
// Contracts limits the query to the given layers, sqlc or proto.
Contracts(contracts ...entlite.Layer) QueryOperations
}
QueryOperations exposes the modifiers available on a plain query.
func GetBy ¶
func GetBy(fields ...string) QueryOperations
GetBy gets a record by one or more fields, e.g. GetBy("id") or GetBy("org_id", "email")
type Type ¶
type Type string
Type tells which kind of query is described.
const ( // TypeDefaultCRUD expands to the common create, read, update and delete queries. TypeDefaultCRUD Type = "default_crud" // TypeCreate inserts one row. TypeCreate Type = "create" // TypeCreateBulk inserts many rows in one call. TypeCreateBulk Type = "create_bulk" // TypeGet reads one row by primary key. TypeGet Type = "get" // TypeUpdate updates one row by primary key. TypeUpdate Type = "update" // TypeDelete deletes one row by primary key. TypeDelete Type = "delete" // TypeDeleteAll deletes every row of the table. TypeDeleteAll Type = "delete_all" // TypeListAll reads every row of the table. TypeListAll Type = "list_all" // TypeGetBy reads one row by the given fields. TypeGetBy Type = "get_by" // TypeListBy reads many rows by the given filters. TypeListBy Type = "list_by" )