qb

package
v2.0.0-...-c0d55de Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

GoCQLX Query Builder

Package qb provides CQL query builders. The builders create CQL statement and a list of named parameters that can later be bound using gocqlx.

The following CQL commands are supported: SELECT, INSERT, UPDATE, DELETE and BATCH.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(column, name string) string

As is a helper for adding a column AS name result column to the query.

func TTL

func TTL(d time.Duration) int64

TTL converts duration to format expected in USING TTL clause.

func Timestamp

func Timestamp(t time.Time) int64

Timestamp converts time to format expected in USING TIMESTAMP clause.

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

func (b *BatchBuilder) Query(session gocqlx.Session) *gocqlx.Queryx

Query returns query built on top of current BatchBuilder state.

func (*BatchBuilder) QueryContext

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

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

func (b *BatchBuilder) Timeout(d time.Duration) *BatchBuilder

Timeout adds USING TIMEOUT clause to the query.

func (*BatchBuilder) TimeoutNamed

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 Contains

func Contains(column string) Cmp

Contains produces column CONTAINS ?.

func ContainsKey

func ContainsKey(column string) Cmp

ContainsKey produces column CONTAINS KEY ?.

func ContainsKeyNamed

func ContainsKeyNamed(column, name string) Cmp

ContainsKeyNamed produces column CONTAINS KEY ? with a custom parameter name.

func ContainsKeyTuple

func ContainsKeyTuple(column string, count int) Cmp

ContainsKeyTuple produces column CONTAINS KEY (?,?,...) with count placehplders.

func ContainsKeyTupleNamed

func ContainsKeyTupleNamed(column string, count int, name string) Cmp

ContainsKeyTupleNamed produces column CONTAINS KEY (?,?,...) with count placehplders and custom name.

func ContainsLit

func ContainsLit(column, literal string) Cmp

ContainsLit produces column CONTAINS literal and does not add a parameter to the query.

func ContainsNamed

func ContainsNamed(column, name string) Cmp

ContainsNamed produces column CONTAINS ? with a custom parameter name.

func ContainsTuple

func ContainsTuple(column string, count int) Cmp

ContainsTuple produces column CONTAINS (?,?,...) with count placeholders.

func ContainsTupleNamed

func ContainsTupleNamed(column string, count int, name string) Cmp

ContainsTupleNamed produces column CONTAINS (?,?,...) with count placeholders and custom name.

func Eq

func Eq(column string) Cmp

Eq produces column=?.

func EqFunc

func EqFunc(column string, fn *Func) Cmp

EqFunc produces column=someFunc(?...).

func EqLit

func EqLit(column, literal string) Cmp

EqLit produces column=literal and does not add a parameter to the query.

func EqNamed

func EqNamed(column, name string) Cmp

EqNamed produces column=? with a custom parameter name.

func EqTuple

func EqTuple(column string, count int) Cmp

EqTuple produces column=(?,?,...) with count number of placeholders.

func EqTupleNamed

func EqTupleNamed(column string, count int, name string) Cmp

EqTupleNamed produces column=(?,?,...) with count number of placeholders and custom name.

func Gt

func Gt(column string) Cmp

Gt produces column>?.

func GtFunc

func GtFunc(column string, fn *Func) Cmp

GtFunc produces column>someFunc(?...).

func GtLit

func GtLit(column, literal string) Cmp

GtLit produces column>literal and does not add a parameter to the query.

func GtNamed

func GtNamed(column, name string) Cmp

GtNamed produces column>? with a custom parameter name.

func GtOrEq

func GtOrEq(column string) Cmp

GtOrEq produces column>=?.

func GtOrEqFunc

func GtOrEqFunc(column string, fn *Func) Cmp

GtOrEqFunc produces column>=someFunc(?...).

func GtOrEqLit

func GtOrEqLit(column, literal string) Cmp

GtOrEqLit produces column>=literal and does not add a parameter to the query.

func GtOrEqNamed

func GtOrEqNamed(column, name string) Cmp

GtOrEqNamed produces column>=? with a custom parameter name.

func GtOrEqTuple

func GtOrEqTuple(column string, count int) Cmp

GtOrEqTuple produces column>=(?,?,...) with count placeholders.

func GtOrEqTupleNamed

func GtOrEqTupleNamed(column string, count int, name string) Cmp

GtOrEqTupleNamed produces column>=(?,?,...) with count placeholders and custom name.

func GtTuple

func GtTuple(column string, count int) Cmp

GtTuple produces column>(?,?,...) with count placeholders.

func GtTupleNamed

func GtTupleNamed(column string, count int, name string) Cmp

GtTupleNamed produces column>(?,?,...) with count placeholders and custom name.

func In

func In(column string) Cmp

In produces column IN ?.

func InLit

func InLit(column, literal string) Cmp

InLit produces column IN literal and does not add a parameter to the query.

func InNamed

func InNamed(column, name string) Cmp

InNamed produces column IN ? with a custom parameter name.

func InTuple

func InTuple(column string, count int) Cmp

InTuple produces column IN ?.

func InTupleNamed

func InTupleNamed(column string, count int, name string) Cmp

InTupleNamed produces column IN ? with a custom parameter name.

func Like

func Like(column string) Cmp

Like produces column LIKE ?.

func LikeTuple

func LikeTuple(column string, count int) Cmp

LikeTuple produces column LIKE (?,?,...) with count placeholders.

func LikeTupleNamed

func LikeTupleNamed(column string, count int, name string) Cmp

LikeTupleNamed produces column LIKE (?,?,...) with count placeholders and custom name.

func Lt

func Lt(column string) Cmp

Lt produces column<?.

func LtFunc

func LtFunc(column string, fn *Func) Cmp

LtFunc produces column<someFunc(?...).

func LtLit

func LtLit(column, literal string) Cmp

LtLit produces column<literal and does not add a parameter to the query.

func LtNamed

func LtNamed(column, name string) Cmp

LtNamed produces column<? with a custom parameter name.

func LtOrEq

func LtOrEq(column string) Cmp

LtOrEq produces column<=?.

func LtOrEqFunc

func LtOrEqFunc(column string, fn *Func) Cmp

LtOrEqFunc produces column<=someFunc(?...).

func LtOrEqLit

func LtOrEqLit(column, literal string) Cmp

LtOrEqLit produces column<=literal and does not add a parameter to the query.

func LtOrEqNamed

func LtOrEqNamed(column, name string) Cmp

LtOrEqNamed produces column<=? with a custom parameter name.

func LtOrEqTuple

func LtOrEqTuple(column string, count int) Cmp

LtOrEqTuple produces column<=(?,?,...) with count placeholders.

func LtOrEqTupleNamed

func LtOrEqTupleNamed(column string, count int, name string) Cmp

LtOrEqTupleNamed produces column<=(?,?,...) with count placeholders and custom name.

func LtTuple

func LtTuple(column string, count int) Cmp

LtTuple produces column<(?,?,...) with count placeholders.

func LtTupleNamed

func LtTupleNamed(column string, count int, name string) Cmp

LtTupleNamed produces column<(?,?,...) with count placeholders and custom name.

func Ne

func Ne(column string) Cmp

Ne produces column!=?.

func NeFunc

func NeFunc(column string, fn *Func) Cmp

NeFunc produces column!=someFunc(?...).

func NeLit

func NeLit(column, literal string) Cmp

NeLit produces column!=literal and does not add a parameter to the query.

func NeNamed

func NeNamed(column, name string) Cmp

NeNamed produces column!=? with a custom parameter name.

func NeTuple

func NeTuple(column string, count int) Cmp

NeTuple produces column!=(?,?,...) with count number of placeholders.

func NeTupleNamed

func NeTupleNamed(column string, count int, name string) Cmp

NeTupleNamed produces column!=(?,?,...) with count number of 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

func (b *DeleteBuilder) Query(session gocqlx.Session) *gocqlx.Queryx

Query returns query built on top of current DeleteBuilder state.

func (*DeleteBuilder) QueryContext

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

func (b *DeleteBuilder) Timeout(d time.Duration) *DeleteBuilder

Timeout adds USING TIMEOUT clause to the query.

func (*DeleteBuilder) TimeoutNamed

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.

func Fn

func Fn(name string, paramNames ...string) *Func

Fn creates Func.

func MaxTimeuuid

func MaxTimeuuid(name string) *Func

MaxTimeuuid produces maxTimeuuid(?).

func MinTimeuuid

func MinTimeuuid(name string) *Func

MinTimeuuid produces minTimeuuid(?).

func Now

func Now() *Func

Now produces now().

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

func (b *InsertBuilder) Query(session gocqlx.Session) *gocqlx.Queryx

Query returns query built on top of current InsertBuilder state.

func (*InsertBuilder) QueryContext

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

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

func (b *InsertBuilder) Timeout(d time.Duration) *InsertBuilder

Timeout adds USING TIMEOUT clause to the query.

func (*InsertBuilder) TimeoutNamed

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 M

type M map[string]interface{}

M is a map.

type Order

type Order bool

Order specifies sorting order.

const (
	// ASC is ascending order
	ASC Order = true
	// DESC is descending order
	DESC Order = false
)

func (Order) String

func (o Order) String() string

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

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

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

func (b *SelectBuilder) Query(session gocqlx.Session) *gocqlx.Queryx

Query returns query built on top of current SelectBuilder state.

func (*SelectBuilder) QueryContext

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

func (b *SelectBuilder) Timeout(d time.Duration) *SelectBuilder

Timeout adds USING TIMEOUT clause to the query.

func (*SelectBuilder) TimeoutNamed

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 Token

func Token(columns ...string) TokenBuilder

Token creates a new TokenBuilder.

func (TokenBuilder) Eq

func (t TokenBuilder) Eq() Cmp

Eq produces token(column)=token(?).

func (TokenBuilder) EqNamed

func (t TokenBuilder) EqNamed(names ...string) Cmp

EqNamed produces token(column)=token(?) with a custom parameter name.

func (TokenBuilder) EqValue

func (t TokenBuilder) EqValue() Cmp

EqValue produces token(column)=?

func (TokenBuilder) EqValueNamed

func (t TokenBuilder) EqValueNamed(name string) Cmp

EqValueNamed produces token(column)=? with a custom parameter name.

func (TokenBuilder) Gt

func (t TokenBuilder) Gt() Cmp

Gt produces token(column)>token(?).

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) GtValue

func (t TokenBuilder) GtValue() Cmp

GtValue produces token(column)>?.

func (TokenBuilder) GtValueNamed

func (t TokenBuilder) GtValueNamed(name string) Cmp

GtValueNamed produces token(column)>? with a custom parameter name.

func (TokenBuilder) Lt

func (t TokenBuilder) Lt() Cmp

Lt produces token(column)<token(?).

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) LtValue

func (t TokenBuilder) LtValue() Cmp

LtValue produces token(column)<?.

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

func (b *UpdateBuilder) Query(session gocqlx.Session) *gocqlx.Queryx

Query returns query built on top of current UpdateBuilder state.

func (*UpdateBuilder) QueryContext

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

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

func (b *UpdateBuilder) Timeout(d time.Duration) *UpdateBuilder

Timeout adds USING TIMEOUT clause to the query.

func (*UpdateBuilder) TimeoutNamed

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.

Jump to

Keyboard shortcuts

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