Documentation ¶
Overview ¶
Package qb provides CQL query builders. The builders create CQL statement and a list of named parameters that can later be bound using gocqlx.
Index ¶
- func As(column, name string) string
- func TTL(d time.Duration) int64
- func Timestamp(t time.Time) int64
- type BatchBuilder
- func Batch() *BatchBuilderdeprecated
- func (b *BatchBuilder) Add(builder Builder) *BatchBuilder
- func (b *BatchBuilder) AddStmt(stmt string, names []string) *BatchBuilder
- func (b *BatchBuilder) AddStmtWithPrefix(prefix, stmt string, names []string) *BatchBuilder
- func (b *BatchBuilder) AddWithPrefix(prefix string, builder Builder) *BatchBuilder
- func (b *BatchBuilder) Counter() *BatchBuilder
- func (b *BatchBuilder) Query(session gocqlx.Session) *gocqlx.Queryx
- func (b *BatchBuilder) QueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx
- func (b *BatchBuilder) TTL(d time.Duration) *BatchBuilder
- func (b *BatchBuilder) TTLNamed(name string) *BatchBuilder
- func (b *BatchBuilder) Timeout(d time.Duration) *BatchBuilder
- func (b *BatchBuilder) TimeoutNamed(name string) *BatchBuilder
- func (b *BatchBuilder) Timestamp(t time.Time) *BatchBuilder
- func (b *BatchBuilder) TimestampNamed(name string) *BatchBuilder
- func (b *BatchBuilder) ToCql() (stmt string, names []string)
- func (b *BatchBuilder) UnLogged() *BatchBuilder
- type Builder
- type Cmp
- func Contains(column string) Cmp
- func ContainsKey(column string) Cmp
- func ContainsKeyNamed(column, name string) Cmp
- func ContainsKeyTuple(column string, count int) Cmp
- func ContainsKeyTupleNamed(column string, count int, name string) Cmp
- func ContainsLit(column, literal string) Cmp
- func ContainsNamed(column, name string) Cmp
- func ContainsTuple(column string, count int) Cmp
- func ContainsTupleNamed(column string, count int, name string) Cmp
- func Eq(column string) Cmp
- func EqFunc(column string, fn *Func) Cmp
- func EqLit(column, literal string) Cmp
- func EqNamed(column, name string) Cmp
- func EqTuple(column string, count int) Cmp
- func EqTupleNamed(column string, count int, name string) Cmp
- func Gt(column string) Cmp
- func GtFunc(column string, fn *Func) Cmp
- func GtLit(column, literal string) Cmp
- func GtNamed(column, name string) Cmp
- func GtOrEq(column string) Cmp
- func GtOrEqFunc(column string, fn *Func) Cmp
- func GtOrEqLit(column, literal string) Cmp
- func GtOrEqNamed(column, name string) Cmp
- func GtOrEqTuple(column string, count int) Cmp
- func GtOrEqTupleNamed(column string, count int, name string) Cmp
- func GtTuple(column string, count int) Cmp
- func GtTupleNamed(column string, count int, name string) Cmp
- func In(column string) Cmp
- func InLit(column, literal string) Cmp
- func InNamed(column, name string) Cmp
- func InTuple(column string, count int) Cmp
- func InTupleNamed(column string, count int, name string) Cmp
- func Like(column string) Cmp
- func LikeTuple(column string, count int) Cmp
- func LikeTupleNamed(column string, count int, name string) Cmp
- func Lt(column string) Cmp
- func LtFunc(column string, fn *Func) Cmp
- func LtLit(column, literal string) Cmp
- func LtNamed(column, name string) Cmp
- func LtOrEq(column string) Cmp
- func LtOrEqFunc(column string, fn *Func) Cmp
- func LtOrEqLit(column, literal string) Cmp
- func LtOrEqNamed(column, name string) Cmp
- func LtOrEqTuple(column string, count int) Cmp
- func LtOrEqTupleNamed(column string, count int, name string) Cmp
- func LtTuple(column string, count int) Cmp
- func LtTupleNamed(column string, count int, name string) Cmp
- func Ne(column string) Cmp
- func NeFunc(column string, fn *Func) Cmp
- func NeLit(column, literal string) Cmp
- func NeNamed(column, name string) Cmp
- func NeTuple(column string, count int) Cmp
- func NeTupleNamed(column string, count int, name string) Cmp
- type DeleteBuilder
- func (b *DeleteBuilder) Columns(columns ...string) *DeleteBuilder
- func (b *DeleteBuilder) Existing() *DeleteBuilder
- func (b *DeleteBuilder) From(table string) *DeleteBuilder
- func (b *DeleteBuilder) If(w ...Cmp) *DeleteBuilder
- func (b *DeleteBuilder) Query(session gocqlx.Session) *gocqlx.Queryx
- func (b *DeleteBuilder) QueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx
- func (b *DeleteBuilder) Timeout(d time.Duration) *DeleteBuilder
- func (b *DeleteBuilder) TimeoutNamed(name string) *DeleteBuilder
- func (b *DeleteBuilder) Timestamp(t time.Time) *DeleteBuilder
- func (b *DeleteBuilder) TimestampNamed(name string) *DeleteBuilder
- func (b *DeleteBuilder) ToCql() (stmt string, names []string)
- func (b *DeleteBuilder) Where(w ...Cmp) *DeleteBuilder
- type Func
- type InsertBuilder
- func (b *InsertBuilder) Columns(columns ...string) *InsertBuilder
- func (b *InsertBuilder) FuncColumn(column string, fn *Func) *InsertBuilder
- func (b *InsertBuilder) Into(table string) *InsertBuilder
- func (b *InsertBuilder) Json() *InsertBuilder
- func (b *InsertBuilder) LitColumn(column, literal string) *InsertBuilder
- func (b *InsertBuilder) NamedColumn(column, name string) *InsertBuilder
- func (b *InsertBuilder) Query(session gocqlx.Session) *gocqlx.Queryx
- func (b *InsertBuilder) QueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx
- func (b *InsertBuilder) TTL(d time.Duration) *InsertBuilder
- func (b *InsertBuilder) TTLNamed(name string) *InsertBuilder
- func (b *InsertBuilder) Timeout(d time.Duration) *InsertBuilder
- func (b *InsertBuilder) TimeoutNamed(name string) *InsertBuilder
- func (b *InsertBuilder) Timestamp(t time.Time) *InsertBuilder
- func (b *InsertBuilder) TimestampNamed(name string) *InsertBuilder
- func (b *InsertBuilder) ToCql() (stmt string, names []string)
- func (b *InsertBuilder) TupleColumn(column string, count int) *InsertBuilder
- func (b *InsertBuilder) Unique() *InsertBuilder
- type M
- type Order
- type SelectBuilder
- func (b *SelectBuilder) AllowFiltering() *SelectBuilder
- func (b *SelectBuilder) Avg(column string) *SelectBuilder
- func (b *SelectBuilder) BypassCache() *SelectBuilder
- func (b *SelectBuilder) Columns(columns ...string) *SelectBuilder
- func (b *SelectBuilder) Count(column string) *SelectBuilder
- func (b *SelectBuilder) CountAll() *SelectBuilder
- func (b *SelectBuilder) Distinct(columns ...string) *SelectBuilder
- func (b *SelectBuilder) From(table string) *SelectBuilder
- func (b *SelectBuilder) GroupBy(columns ...string) *SelectBuilder
- func (b *SelectBuilder) Json() *SelectBuilder
- func (b *SelectBuilder) Limit(limit uint) *SelectBuilder
- func (b *SelectBuilder) LimitNamed(name string) *SelectBuilder
- func (b *SelectBuilder) LimitPerPartition(limit uint) *SelectBuilder
- func (b *SelectBuilder) LimitPerPartitionNamed(name string) *SelectBuilder
- func (b *SelectBuilder) Max(column string) *SelectBuilder
- func (b *SelectBuilder) Min(column string) *SelectBuilder
- func (b *SelectBuilder) OrderBy(column string, o Order) *SelectBuilder
- func (b *SelectBuilder) Query(session gocqlx.Session) *gocqlx.Queryx
- func (b *SelectBuilder) QueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx
- func (b *SelectBuilder) Sum(column string) *SelectBuilder
- func (b *SelectBuilder) Timeout(d time.Duration) *SelectBuilder
- func (b *SelectBuilder) TimeoutNamed(name string) *SelectBuilder
- func (b *SelectBuilder) ToCql() (stmt string, names []string)
- func (b *SelectBuilder) Where(w ...Cmp) *SelectBuilder
- type TokenBuilder
- func (t TokenBuilder) Eq() Cmp
- func (t TokenBuilder) EqNamed(names ...string) Cmp
- func (t TokenBuilder) EqValue() Cmp
- func (t TokenBuilder) EqValueNamed(name string) Cmp
- func (t TokenBuilder) Gt() Cmp
- func (t TokenBuilder) GtNamed(names ...string) Cmp
- func (t TokenBuilder) GtOrEq() Cmp
- func (t TokenBuilder) GtOrEqNamed(names ...string) Cmp
- func (t TokenBuilder) GtOrEqValue() Cmp
- func (t TokenBuilder) GtOrEqValueNamed(name string) Cmp
- func (t TokenBuilder) GtValue() Cmp
- func (t TokenBuilder) GtValueNamed(name string) Cmp
- func (t TokenBuilder) Lt() Cmp
- func (t TokenBuilder) LtNamed(names ...string) Cmp
- func (t TokenBuilder) LtOrEq() Cmp
- func (t TokenBuilder) LtOrEqNamed(names ...string) Cmp
- func (t TokenBuilder) LtOrEqValue() Cmp
- func (t TokenBuilder) LtOrEqValueNamed(name string) Cmp
- func (t TokenBuilder) LtValue() Cmp
- func (t TokenBuilder) LtValueNamed(name string) Cmp
- type UpdateBuilder
- func (b *UpdateBuilder) Add(column string) *UpdateBuilder
- func (b *UpdateBuilder) AddFunc(column string, fn *Func) *UpdateBuilder
- func (b *UpdateBuilder) AddLit(column, literal string) *UpdateBuilder
- func (b *UpdateBuilder) AddNamed(column, name string) *UpdateBuilder
- func (b *UpdateBuilder) Existing() *UpdateBuilder
- func (b *UpdateBuilder) If(w ...Cmp) *UpdateBuilder
- func (b *UpdateBuilder) Query(session gocqlx.Session) *gocqlx.Queryx
- func (b *UpdateBuilder) QueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx
- func (b *UpdateBuilder) Remove(column string) *UpdateBuilder
- func (b *UpdateBuilder) RemoveFunc(column string, fn *Func) *UpdateBuilder
- func (b *UpdateBuilder) RemoveLit(column, literal string) *UpdateBuilder
- func (b *UpdateBuilder) RemoveNamed(column, name string) *UpdateBuilder
- func (b *UpdateBuilder) Set(columns ...string) *UpdateBuilder
- func (b *UpdateBuilder) SetFunc(column string, fn *Func) *UpdateBuilder
- func (b *UpdateBuilder) SetLit(column, literal string) *UpdateBuilder
- func (b *UpdateBuilder) SetNamed(column, name string) *UpdateBuilder
- func (b *UpdateBuilder) SetTuple(column string, count int) *UpdateBuilder
- func (b *UpdateBuilder) TTL(d time.Duration) *UpdateBuilder
- func (b *UpdateBuilder) TTLNamed(name string) *UpdateBuilder
- func (b *UpdateBuilder) Table(table string) *UpdateBuilder
- func (b *UpdateBuilder) Timeout(d time.Duration) *UpdateBuilder
- func (b *UpdateBuilder) TimeoutNamed(name string) *UpdateBuilder
- func (b *UpdateBuilder) Timestamp(t time.Time) *UpdateBuilder
- func (b *UpdateBuilder) TimestampNamed(name string) *UpdateBuilder
- func (b *UpdateBuilder) ToCql() (stmt string, names []string)
- func (b *UpdateBuilder) Where(w ...Cmp) *UpdateBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BatchBuilder ¶
type BatchBuilder struct {
// contains filtered or unexported fields
}
BatchBuilder builds CQL BATCH statements.
func Batch
deprecated
func Batch() *BatchBuilder
Batch returns a new BatchBuilder. BatchBuilder encapsulates batch cqls as one ordinary gocql.Query for convenience. Below are the limitations of encapsulating batch cqls based on gocql.Query instead of gocql.Batch:
- gocql.Batch has some more batch specific check, such as BatchSize(65535).
- gocql.Batch use BatchObserver instead of QueryObserver.
- gocql.Batch has cancelBatch call back.
- gocql.Batch prepares the included statements separately, which is more efficient. In contrast, gocqlx.qb.BatchBuilder, which is based on gocql.Query, prepares the whole batch statements as one ordinary query.
Deprecated: Please use gocql.Session.NewBatch() instead.
func (*BatchBuilder) Add ¶
func (b *BatchBuilder) Add(builder Builder) *BatchBuilder
Add builds the builder and adds the statement to the batch.
func (*BatchBuilder) AddStmt ¶
func (b *BatchBuilder) AddStmt(stmt string, names []string) *BatchBuilder
AddStmt adds statement to the batch.
func (*BatchBuilder) AddStmtWithPrefix ¶
func (b *BatchBuilder) AddStmtWithPrefix(prefix, stmt string, names []string) *BatchBuilder
AddStmtWithPrefix adds statement to the batch. Names are prefixed with the prefix + ".".
func (*BatchBuilder) AddWithPrefix ¶
func (b *BatchBuilder) AddWithPrefix(prefix string, builder Builder) *BatchBuilder
AddWithPrefix builds the builder and adds the statement to the batch. Names are prefixed with the prefix + ".".
func (*BatchBuilder) Counter ¶
func (b *BatchBuilder) Counter() *BatchBuilder
Counter sets a COUNTER BATCH clause on the query.
func (*BatchBuilder) Query ¶ added in v2.1.0
func (b *BatchBuilder) Query(session gocqlx.Session) *gocqlx.Queryx
Query returns query built on top of current BatchBuilder state.
func (*BatchBuilder) QueryContext ¶ added in v2.1.0
func (b *BatchBuilder) QueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx
QueryContext returns query wrapped with context built on top of current BatchBuilder state.
func (*BatchBuilder) TTL ¶
func (b *BatchBuilder) TTL(d time.Duration) *BatchBuilder
TTL adds USING TTL clause to the query.
func (*BatchBuilder) TTLNamed ¶
func (b *BatchBuilder) TTLNamed(name string) *BatchBuilder
TTLNamed adds USING TTL clause to the query with a custom parameter name.
func (*BatchBuilder) Timeout ¶ added in v2.5.0
func (b *BatchBuilder) Timeout(d time.Duration) *BatchBuilder
Timeout adds USING TIMEOUT clause to the query.
func (*BatchBuilder) TimeoutNamed ¶ added in v2.5.0
func (b *BatchBuilder) TimeoutNamed(name string) *BatchBuilder
TimeoutNamed adds a USING TIMEOUT clause to the query with a custom parameter name.
func (*BatchBuilder) Timestamp ¶
func (b *BatchBuilder) Timestamp(t time.Time) *BatchBuilder
Timestamp adds USING TIMESTAMP clause to the query.
func (*BatchBuilder) TimestampNamed ¶
func (b *BatchBuilder) TimestampNamed(name string) *BatchBuilder
TimestampNamed adds a USING TIMESTAMP clause to the query with a custom parameter name.
func (*BatchBuilder) ToCql ¶
func (b *BatchBuilder) ToCql() (stmt string, names []string)
ToCql builds the query into a CQL string and named args.
func (*BatchBuilder) UnLogged ¶
func (b *BatchBuilder) UnLogged() *BatchBuilder
UnLogged sets a UNLOGGED BATCH clause on the query.
type Builder ¶
type Builder interface { // ToCql builds the query into a CQL string and named args. ToCql() (stmt string, names []string) }
Builder is interface implemented by all the builders.
type Cmp ¶
type Cmp struct {
// contains filtered or unexported fields
}
Cmp if a filtering comparator that is used in WHERE and IF clauses.
func ContainsKeyNamed ¶
ContainsKeyNamed produces column CONTAINS KEY ? with a custom parameter name.
func ContainsKeyTuple ¶
ContainsKeyTuple produces column CONTAINS KEY (?,?,...) with count placehplders.
func ContainsKeyTupleNamed ¶ added in v2.7.0
ContainsKeyTupleNamed produces column CONTAINS KEY (?,?,...) with count placehplders and custom name.
func ContainsLit ¶
ContainsLit produces column CONTAINS literal and does not add a parameter to the query.
func ContainsNamed ¶
ContainsNamed produces column CONTAINS ? with a custom parameter name.
func ContainsTuple ¶
ContainsTuple produces column CONTAINS (?,?,...) with count placeholders.
func ContainsTupleNamed ¶ added in v2.7.0
ContainsTupleNamed produces column CONTAINS (?,?,...) with count placeholders and custom name.
func EqTupleNamed ¶ added in v2.7.0
EqTupleNamed produces column=(?,?,...) with count number of placeholders and custom name.
func GtOrEqFunc ¶
GtOrEqFunc produces column>=someFunc(?...).
func GtOrEqNamed ¶
GtOrEqNamed produces column>=? with a custom parameter name.
func GtOrEqTuple ¶
GtOrEqTuple produces column>=(?,?,...) with count placeholders.
func GtOrEqTupleNamed ¶ added in v2.7.0
GtOrEqTupleNamed produces column>=(?,?,...) with count placeholders and custom name.
func GtTupleNamed ¶ added in v2.7.0
GtTupleNamed produces column>(?,?,...) with count placeholders and custom name.
func InTupleNamed ¶ added in v2.7.0
InTupleNamed produces column IN ? with a custom parameter name.
func LikeTupleNamed ¶ added in v2.7.0
LikeTupleNamed produces column LIKE (?,?,...) with count placeholders and custom name.
func LtOrEqFunc ¶
LtOrEqFunc produces column<=someFunc(?...).
func LtOrEqNamed ¶
LtOrEqNamed produces column<=? with a custom parameter name.
func LtOrEqTuple ¶
LtOrEqTuple produces column<=(?,?,...) with count placeholders.
func LtOrEqTupleNamed ¶ added in v2.7.0
LtOrEqTupleNamed produces column<=(?,?,...) with count placeholders and custom name.
func LtTupleNamed ¶ added in v2.7.0
LtTupleNamed produces column<(?,?,...) with count placeholders and custom name.
type DeleteBuilder ¶
type DeleteBuilder struct {
// contains filtered or unexported fields
}
DeleteBuilder builds CQL DELETE statements.
func Delete ¶
func Delete(table string) *DeleteBuilder
Delete returns a new DeleteBuilder with the given table name.
func (*DeleteBuilder) Columns ¶
func (b *DeleteBuilder) Columns(columns ...string) *DeleteBuilder
Columns adds delete columns to the query.
func (*DeleteBuilder) Existing ¶
func (b *DeleteBuilder) Existing() *DeleteBuilder
Existing sets a IF EXISTS clause on the query.
func (*DeleteBuilder) From ¶
func (b *DeleteBuilder) From(table string) *DeleteBuilder
From sets the table to be deleted from.
func (*DeleteBuilder) If ¶
func (b *DeleteBuilder) If(w ...Cmp) *DeleteBuilder
If adds an expression to the IF clause of the query. Expressions are ANDed together in the generated CQL.
func (*DeleteBuilder) Query ¶ added in v2.1.0
func (b *DeleteBuilder) Query(session gocqlx.Session) *gocqlx.Queryx
Query returns query built on top of current DeleteBuilder state.
func (*DeleteBuilder) QueryContext ¶ added in v2.1.0
func (b *DeleteBuilder) QueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx
QueryContext returns query wrapped with context built on top of current DeleteBuilder state.
func (*DeleteBuilder) Timeout ¶ added in v2.5.0
func (b *DeleteBuilder) Timeout(d time.Duration) *DeleteBuilder
Timeout adds USING TIMEOUT clause to the query.
func (*DeleteBuilder) TimeoutNamed ¶ added in v2.5.0
func (b *DeleteBuilder) TimeoutNamed(name string) *DeleteBuilder
TimeoutNamed adds a USING TIMEOUT clause to the query with a custom parameter name.
func (*DeleteBuilder) Timestamp ¶
func (b *DeleteBuilder) Timestamp(t time.Time) *DeleteBuilder
Timestamp adds USING TIMESTAMP clause to the query.
func (*DeleteBuilder) TimestampNamed ¶
func (b *DeleteBuilder) TimestampNamed(name string) *DeleteBuilder
TimestampNamed adds a USING TIMESTAMP clause to the query with a custom parameter name.
func (*DeleteBuilder) ToCql ¶
func (b *DeleteBuilder) ToCql() (stmt string, names []string)
ToCql builds the query into a CQL string and named args.
func (*DeleteBuilder) Where ¶
func (b *DeleteBuilder) Where(w ...Cmp) *DeleteBuilder
Where adds an expression to the WHERE clause of the query. Expressions are ANDed together in the generated CQL.
type Func ¶
type Func struct { // function name Name string // name of the function parameters ParamNames []string }
Func is a custom database function invocation that can be use in a comparator or update statement.
type InsertBuilder ¶
type InsertBuilder struct {
// contains filtered or unexported fields
}
InsertBuilder builds CQL INSERT statements.
func Insert ¶
func Insert(table string) *InsertBuilder
Insert returns a new InsertBuilder with the given table name.
func (*InsertBuilder) Columns ¶
func (b *InsertBuilder) Columns(columns ...string) *InsertBuilder
Columns adds insert columns to the query.
func (*InsertBuilder) FuncColumn ¶
func (b *InsertBuilder) FuncColumn(column string, fn *Func) *InsertBuilder
FuncColumn adds an insert column initialized by evaluating a CQL function.
func (*InsertBuilder) Into ¶
func (b *InsertBuilder) Into(table string) *InsertBuilder
Into sets the INTO clause of the query.
func (*InsertBuilder) Json ¶
func (b *InsertBuilder) Json() *InsertBuilder
Json sets the Json clause of the query.
func (*InsertBuilder) LitColumn ¶
func (b *InsertBuilder) LitColumn(column, literal string) *InsertBuilder
LitColumn adds an insert column with a literal value to the query.
func (*InsertBuilder) NamedColumn ¶
func (b *InsertBuilder) NamedColumn(column, name string) *InsertBuilder
NamedColumn adds an insert column with a custom parameter name.
func (*InsertBuilder) Query ¶ added in v2.1.0
func (b *InsertBuilder) Query(session gocqlx.Session) *gocqlx.Queryx
Query returns query built on top of current InsertBuilder state.
func (*InsertBuilder) QueryContext ¶ added in v2.1.0
func (b *InsertBuilder) QueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx
QueryContext returns query wrapped with context built on top of current InsertBuilder state.
func (*InsertBuilder) TTL ¶
func (b *InsertBuilder) TTL(d time.Duration) *InsertBuilder
TTL adds USING TTL clause to the query.
func (*InsertBuilder) TTLNamed ¶
func (b *InsertBuilder) TTLNamed(name string) *InsertBuilder
TTLNamed adds USING TTL clause to the query with a custom parameter name.
func (*InsertBuilder) Timeout ¶ added in v2.5.0
func (b *InsertBuilder) Timeout(d time.Duration) *InsertBuilder
Timeout adds USING TIMEOUT clause to the query.
func (*InsertBuilder) TimeoutNamed ¶ added in v2.5.0
func (b *InsertBuilder) TimeoutNamed(name string) *InsertBuilder
TimeoutNamed adds a USING TIMEOUT clause to the query with a custom parameter name.
func (*InsertBuilder) Timestamp ¶
func (b *InsertBuilder) Timestamp(t time.Time) *InsertBuilder
Timestamp adds USING TIMESTAMP clause to the query.
func (*InsertBuilder) TimestampNamed ¶
func (b *InsertBuilder) TimestampNamed(name string) *InsertBuilder
TimestampNamed adds a USING TIMESTAMP clause to the query with a custom parameter name.
func (*InsertBuilder) ToCql ¶
func (b *InsertBuilder) ToCql() (stmt string, names []string)
ToCql builds the query into a CQL string and named args.
func (*InsertBuilder) TupleColumn ¶
func (b *InsertBuilder) TupleColumn(column string, count int) *InsertBuilder
TupleColumn adds an insert column for a tuple value to the query.
func (*InsertBuilder) Unique ¶
func (b *InsertBuilder) Unique() *InsertBuilder
Unique sets a IF NOT EXISTS clause on the query.
type SelectBuilder ¶
type SelectBuilder struct {
// contains filtered or unexported fields
}
SelectBuilder builds CQL SELECT statements.
func Select ¶
func Select(table string) *SelectBuilder
Select returns a new SelectBuilder with the given table name.
func (*SelectBuilder) AllowFiltering ¶
func (b *SelectBuilder) AllowFiltering() *SelectBuilder
AllowFiltering sets a ALLOW FILTERING clause on the query.
func (*SelectBuilder) Avg ¶
func (b *SelectBuilder) Avg(column string) *SelectBuilder
Avg produces 'avg(column)' aggregation function.
func (*SelectBuilder) BypassCache ¶
func (b *SelectBuilder) BypassCache() *SelectBuilder
BypassCache sets a BYPASS CACHE clause on the query.
BYPASS CACHE is a feature specific to ScyllaDB. See https://docs.scylladb.com/getting-started/dml/#bypass-cache
func (*SelectBuilder) Columns ¶
func (b *SelectBuilder) Columns(columns ...string) *SelectBuilder
Columns adds result columns to the query.
func (*SelectBuilder) Count ¶
func (b *SelectBuilder) Count(column string) *SelectBuilder
Count produces 'count(column)'.
func (*SelectBuilder) CountAll ¶
func (b *SelectBuilder) CountAll() *SelectBuilder
CountAll produces 'count(*)'.
func (*SelectBuilder) Distinct ¶
func (b *SelectBuilder) Distinct(columns ...string) *SelectBuilder
Distinct sets DISTINCT clause on the query.
func (*SelectBuilder) From ¶
func (b *SelectBuilder) From(table string) *SelectBuilder
From sets the table to be selected from.
func (*SelectBuilder) GroupBy ¶
func (b *SelectBuilder) GroupBy(columns ...string) *SelectBuilder
GroupBy sets GROUP BY clause on the query. Columns must be a primary key, this will automatically add the the columns as first selectors.
func (*SelectBuilder) Json ¶
func (b *SelectBuilder) Json() *SelectBuilder
Json sets the clause of the query.
func (*SelectBuilder) Limit ¶
func (b *SelectBuilder) Limit(limit uint) *SelectBuilder
Limit sets a LIMIT clause on the query.
func (*SelectBuilder) LimitNamed ¶ added in v2.6.0
func (b *SelectBuilder) LimitNamed(name string) *SelectBuilder
LimitNamed produces LIMIT ? clause with a custom parameter name.
func (*SelectBuilder) LimitPerPartition ¶
func (b *SelectBuilder) LimitPerPartition(limit uint) *SelectBuilder
LimitPerPartition sets a PER PARTITION LIMIT clause on the query.
func (*SelectBuilder) LimitPerPartitionNamed ¶ added in v2.6.0
func (b *SelectBuilder) LimitPerPartitionNamed(name string) *SelectBuilder
LimitPerPartitionNamed produces PER PARTITION LIMIT ? clause with a custom parameter name.
func (*SelectBuilder) Max ¶
func (b *SelectBuilder) Max(column string) *SelectBuilder
Max produces 'max(column)' aggregation function.
func (*SelectBuilder) Min ¶
func (b *SelectBuilder) Min(column string) *SelectBuilder
Min produces 'min(column)' aggregation function.
func (*SelectBuilder) OrderBy ¶
func (b *SelectBuilder) OrderBy(column string, o Order) *SelectBuilder
OrderBy sets ORDER BY clause on the query.
func (*SelectBuilder) Query ¶ added in v2.1.0
func (b *SelectBuilder) Query(session gocqlx.Session) *gocqlx.Queryx
Query returns query built on top of current SelectBuilder state.
func (*SelectBuilder) QueryContext ¶ added in v2.1.0
func (b *SelectBuilder) QueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx
QueryContext returns query wrapped with context built on top of current SelectBuilder state.
func (*SelectBuilder) Sum ¶
func (b *SelectBuilder) Sum(column string) *SelectBuilder
Sum produces 'sum(column)' aggregation function.
func (*SelectBuilder) Timeout ¶ added in v2.5.0
func (b *SelectBuilder) Timeout(d time.Duration) *SelectBuilder
Timeout adds USING TIMEOUT clause to the query.
func (*SelectBuilder) TimeoutNamed ¶ added in v2.5.0
func (b *SelectBuilder) TimeoutNamed(name string) *SelectBuilder
TimeoutNamed adds a USING TIMEOUT clause to the query with a custom parameter name.
func (*SelectBuilder) ToCql ¶
func (b *SelectBuilder) ToCql() (stmt string, names []string)
ToCql builds the query into a CQL string and named args.
func (*SelectBuilder) Where ¶
func (b *SelectBuilder) Where(w ...Cmp) *SelectBuilder
Where adds an expression to the WHERE clause of the query. Expressions are ANDed together in the generated CQL.
type TokenBuilder ¶
type TokenBuilder []string
TokenBuilder helps implement pagination using token function.
func (TokenBuilder) EqNamed ¶
func (t TokenBuilder) EqNamed(names ...string) Cmp
EqNamed produces token(column)=token(?) with a custom parameter name.
func (TokenBuilder) EqValueNamed ¶
func (t TokenBuilder) EqValueNamed(name string) Cmp
EqValueNamed produces token(column)=? with a custom parameter name.
func (TokenBuilder) GtNamed ¶
func (t TokenBuilder) GtNamed(names ...string) Cmp
GtNamed produces token(column)>token(?) with a custom parameter name.
func (TokenBuilder) GtOrEq ¶
func (t TokenBuilder) GtOrEq() Cmp
GtOrEq produces token(column)>=token(?).
func (TokenBuilder) GtOrEqNamed ¶
func (t TokenBuilder) GtOrEqNamed(names ...string) Cmp
GtOrEqNamed produces token(column)>=token(?) with a custom parameter name.
func (TokenBuilder) GtOrEqValue ¶
func (t TokenBuilder) GtOrEqValue() Cmp
GtOrEqValue produces token(column)>=?.
func (TokenBuilder) GtOrEqValueNamed ¶
func (t TokenBuilder) GtOrEqValueNamed(name string) Cmp
GtOrEqValueNamed produces token(column)>=? with a custom parameter name.
func (TokenBuilder) GtValueNamed ¶
func (t TokenBuilder) GtValueNamed(name string) Cmp
GtValueNamed produces token(column)>? with a custom parameter name.
func (TokenBuilder) LtNamed ¶
func (t TokenBuilder) LtNamed(names ...string) Cmp
LtNamed produces token(column)<token(?) with a custom parameter name.
func (TokenBuilder) LtOrEq ¶
func (t TokenBuilder) LtOrEq() Cmp
LtOrEq produces token(column)<=token(?).
func (TokenBuilder) LtOrEqNamed ¶
func (t TokenBuilder) LtOrEqNamed(names ...string) Cmp
LtOrEqNamed produces token(column)<=token(?) with a custom parameter name.
func (TokenBuilder) LtOrEqValue ¶
func (t TokenBuilder) LtOrEqValue() Cmp
LtOrEqValue produces token(column)<=?.
func (TokenBuilder) LtOrEqValueNamed ¶
func (t TokenBuilder) LtOrEqValueNamed(name string) Cmp
LtOrEqValueNamed produces token(column)<=? with a custom parameter name.
func (TokenBuilder) LtValueNamed ¶
func (t TokenBuilder) LtValueNamed(name string) Cmp
LtValueNamed produces token(column)<? with a custom parameter name.
type UpdateBuilder ¶
type UpdateBuilder struct {
// contains filtered or unexported fields
}
UpdateBuilder builds CQL UPDATE statements.
func Update ¶
func Update(table string) *UpdateBuilder
Update returns a new UpdateBuilder with the given table name.
func (*UpdateBuilder) Add ¶
func (b *UpdateBuilder) Add(column string) *UpdateBuilder
Add adds SET column=column+? clauses to the query.
func (*UpdateBuilder) AddFunc ¶
func (b *UpdateBuilder) AddFunc(column string, fn *Func) *UpdateBuilder
AddFunc adds SET column=column+someFunc(?...) clauses to the query.
func (*UpdateBuilder) AddLit ¶
func (b *UpdateBuilder) AddLit(column, literal string) *UpdateBuilder
AddLit adds SET column=column+literal clauses to the query.
func (*UpdateBuilder) AddNamed ¶
func (b *UpdateBuilder) AddNamed(column, name string) *UpdateBuilder
AddNamed adds SET column=column+? clauses to the query with a custom parameter name.
func (*UpdateBuilder) Existing ¶
func (b *UpdateBuilder) Existing() *UpdateBuilder
Existing sets a IF EXISTS clause on the query.
func (*UpdateBuilder) If ¶
func (b *UpdateBuilder) If(w ...Cmp) *UpdateBuilder
If adds an expression to the IF clause of the query. Expressions are ANDed together in the generated CQL.
func (*UpdateBuilder) Query ¶ added in v2.1.0
func (b *UpdateBuilder) Query(session gocqlx.Session) *gocqlx.Queryx
Query returns query built on top of current UpdateBuilder state.
func (*UpdateBuilder) QueryContext ¶ added in v2.1.0
func (b *UpdateBuilder) QueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx
QueryContext returns query wrapped with context built on top of current UpdateBuilder state.
func (*UpdateBuilder) Remove ¶
func (b *UpdateBuilder) Remove(column string) *UpdateBuilder
Remove adds SET column=column-? clauses to the query.
func (*UpdateBuilder) RemoveFunc ¶
func (b *UpdateBuilder) RemoveFunc(column string, fn *Func) *UpdateBuilder
RemoveFunc adds SET column=column-someFunc(?...) clauses to the query.
func (*UpdateBuilder) RemoveLit ¶
func (b *UpdateBuilder) RemoveLit(column, literal string) *UpdateBuilder
RemoveLit adds SET column=column-literal clauses to the query.
func (*UpdateBuilder) RemoveNamed ¶
func (b *UpdateBuilder) RemoveNamed(column, name string) *UpdateBuilder
RemoveNamed adds SET column=column-? clauses to the query with a custom parameter name.
func (*UpdateBuilder) Set ¶
func (b *UpdateBuilder) Set(columns ...string) *UpdateBuilder
Set adds SET clauses to the query. To set a tuple column use SetTuple instead.
func (*UpdateBuilder) SetFunc ¶
func (b *UpdateBuilder) SetFunc(column string, fn *Func) *UpdateBuilder
SetFunc adds SET column=someFunc(?...) clause to the query.
func (*UpdateBuilder) SetLit ¶
func (b *UpdateBuilder) SetLit(column, literal string) *UpdateBuilder
SetLit adds SET column=literal clause to the query.
func (*UpdateBuilder) SetNamed ¶
func (b *UpdateBuilder) SetNamed(column, name string) *UpdateBuilder
SetNamed adds SET column=? clause to the query with a custom parameter name.
func (*UpdateBuilder) SetTuple ¶
func (b *UpdateBuilder) SetTuple(column string, count int) *UpdateBuilder
SetTuple adds a SET clause for a tuple to the query.
func (*UpdateBuilder) TTL ¶
func (b *UpdateBuilder) TTL(d time.Duration) *UpdateBuilder
TTL adds USING TTL clause to the query.
func (*UpdateBuilder) TTLNamed ¶
func (b *UpdateBuilder) TTLNamed(name string) *UpdateBuilder
TTLNamed adds USING TTL clause to the query with a custom parameter name.
func (*UpdateBuilder) Table ¶
func (b *UpdateBuilder) Table(table string) *UpdateBuilder
Table sets the table to be updated.
func (*UpdateBuilder) Timeout ¶ added in v2.5.0
func (b *UpdateBuilder) Timeout(d time.Duration) *UpdateBuilder
Timeout adds USING TIMEOUT clause to the query.
func (*UpdateBuilder) TimeoutNamed ¶ added in v2.5.0
func (b *UpdateBuilder) TimeoutNamed(name string) *UpdateBuilder
TimeoutNamed adds a USING TIMEOUT clause to the query with a custom parameter name.
func (*UpdateBuilder) Timestamp ¶
func (b *UpdateBuilder) Timestamp(t time.Time) *UpdateBuilder
Timestamp adds USING TIMESTAMP clause to the query.
func (*UpdateBuilder) TimestampNamed ¶
func (b *UpdateBuilder) TimestampNamed(name string) *UpdateBuilder
TimestampNamed adds a USING TIMESTAMP clause to the query with a custom parameter name.
func (*UpdateBuilder) ToCql ¶
func (b *UpdateBuilder) ToCql() (stmt string, names []string)
ToCql builds the query into a CQL string and named args.
func (*UpdateBuilder) Where ¶
func (b *UpdateBuilder) Where(w ...Cmp) *UpdateBuilder
Where adds an expression to the WHERE clause of the query. Expressions are ANDed together in the generated CQL.