Documentation ¶
Overview ¶
Package ql provides an API for building InfluxQL queries.
Currently it only supports 'SELECT' and and 'SHOW TAG VALUES' queries.
The builders will not ensure that the query returned will be a valid one in terms of completeness. The user of the package is responsible to compose a full query with the builder.
An example of a SELECT query:
ql.Select("a", "b").From("c").Where(ql.Eq(ql.And(), "a", "d", "g"))
Will return:
SELECT a, b FROM c WHERE a='d' AND a='g'
Index ¶
- type Builder
- type Operator
- type OperatorBuilder
- type Querier
- type QueryFunc
- type SelectBuilder
- func (sb *SelectBuilder) ASC() *SelectBuilder
- func (sb *SelectBuilder) From(f ...string) *SelectBuilder
- func (sb *SelectBuilder) GroupBy(column string) *SelectBuilder
- func (sb *SelectBuilder) Limit(l int64) *SelectBuilder
- func (sb *SelectBuilder) OrderBy(column string) *SelectBuilder
- func (sb *SelectBuilder) Query() (string, []interface{})
- func (sb *SelectBuilder) TZ(tz string) *SelectBuilder
- func (sb *SelectBuilder) Where(q ...Querier) *SelectBuilder
- type ShowMeasurementBuilder
- type ShowTagValuesBuilder
- type WhereBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
Builder is the base builder for an Influx QL query.
func (*Builder) AppendWithComma ¶
AppendWithComma appens the given strings and separates them with a comma.
func (*Builder) AppendWithQuotes ¶
AppendWithQuotes appens the given string to the query builder with double quotes.
func (*Builder) AppendWithQuotesAndComma ¶
AppendWithQuotesAndComma appens the given strings with double quotes and separates them with a comma.
type OperatorBuilder ¶
type OperatorBuilder struct {
// contains filtered or unexported fields
}
OperatorBuilder is a builder for combining WHERE clauses with AND and OR operators.
func And ¶
func And() *OperatorBuilder
func Or ¶
func Or() *OperatorBuilder
func (*OperatorBuilder) Query ¶
func (o *OperatorBuilder) Query() (string, []interface{})
type Querier ¶
type Querier interface {
Query() (string, []interface{})
}
Querier interface provides the Query method.
type QueryFunc ¶
type QueryFunc func() (string, []interface{})
The QueryFunc type is an adapter to allow the use of ordinary functions as Querier.
type SelectBuilder ¶
type SelectBuilder struct {
// contains filtered or unexported fields
}
SelectBuilder is a builder for a 'SELECT' query.
func Select ¶
func Select(columns ...string) *SelectBuilder
Select returns the base for building a 'SELECT' query.
func (*SelectBuilder) ASC ¶
func (sb *SelectBuilder) ASC() *SelectBuilder
func (*SelectBuilder) From ¶
func (sb *SelectBuilder) From(f ...string) *SelectBuilder
func (*SelectBuilder) GroupBy ¶
func (sb *SelectBuilder) GroupBy(column string) *SelectBuilder
func (*SelectBuilder) Limit ¶
func (sb *SelectBuilder) Limit(l int64) *SelectBuilder
func (*SelectBuilder) OrderBy ¶
func (sb *SelectBuilder) OrderBy(column string) *SelectBuilder
func (*SelectBuilder) Query ¶
func (sb *SelectBuilder) Query() (string, []interface{})
func (*SelectBuilder) TZ ¶
func (sb *SelectBuilder) TZ(tz string) *SelectBuilder
func (*SelectBuilder) Where ¶
func (sb *SelectBuilder) Where(q ...Querier) *SelectBuilder
type ShowMeasurementBuilder ¶
type ShowMeasurementBuilder struct {
// contains filtered or unexported fields
}
ShowMeasurementBuilder is a builder for a 'SHOW MEASUREMENTS' query.
func ShowMeasurement ¶
func ShowMeasurement() *ShowMeasurementBuilder
ShowMeasurement returns the base for building a 'SHOW MEASUREMENT' query.
func (*ShowMeasurementBuilder) Query ¶
func (sm *ShowMeasurementBuilder) Query() (string, []interface{})
func (*ShowMeasurementBuilder) Where ¶
func (sm *ShowMeasurementBuilder) Where(q ...Querier) *ShowMeasurementBuilder
func (*ShowMeasurementBuilder) With ¶
func (sm *ShowMeasurementBuilder) With(o Operator, regex string) *ShowMeasurementBuilder
type ShowTagValuesBuilder ¶
type ShowTagValuesBuilder struct {
// contains filtered or unexported fields
}
ShowTagValuesBuilder is a builder for a 'SHOW TAG VALUES' query.
func ShowTagValues ¶
func ShowTagValues() *ShowTagValuesBuilder
ShowTagValues returns the base for building a 'SHOW TAG VALUES' query.
func (*ShowTagValuesBuilder) From ¶
func (st *ShowTagValuesBuilder) From(f ...string) *ShowTagValuesBuilder
func (*ShowTagValuesBuilder) Query ¶
func (st *ShowTagValuesBuilder) Query() (string, []interface{})
func (*ShowTagValuesBuilder) Where ¶
func (st *ShowTagValuesBuilder) Where(q ...Querier) *ShowTagValuesBuilder
func (*ShowTagValuesBuilder) WithKeyIn ¶
func (st *ShowTagValuesBuilder) WithKeyIn(tagKeys ...string) *ShowTagValuesBuilder
type WhereBuilder ¶
type WhereBuilder struct {
// contains filtered or unexported fields
}
WhereBuilder is a builder for the 'WHERE' clause of a query.
func Where ¶
func Where(q ...Querier) *WhereBuilder
func (*WhereBuilder) Query ¶
func (wb *WhereBuilder) Query() (string, []interface{})