Documentation ¶
Overview ¶
cqlc generates Go code from your Cassandra schema so that you can write type safe CQL statements in Go with a natural query syntax.
For a full guide visit http://relops.com/cqlc
var FOO = FooTableDef() iter, err := ctx.Select(FOO.BAR). From(FOO). Where(FOO.BAZ.Eq("x")). Fetch(session) var foos []Foo = BindFoos(iter)
Index ¶
- Variables
- func BuildStatement(c *Context) (stmt string, placeHolders []interface{}, err error)
- type ArrayColumn
- type Bindable
- type BindingError
- type BooleanColumn
- type BytesColumn
- type ClusteredBooleanColumn
- type ClusteredBytesColumn
- type ClusteredColumn
- type ClusteredDecimalColumn
- type ClusteredFloat32Column
- type ClusteredFloat64Column
- type ClusteredInt32Column
- type ClusteredInt64Column
- type ClusteredStringColumn
- type ClusteredTimeUUIDColumn
- type ClusteredTimestampColumn
- type Column
- type ColumnBinding
- type CompareAndSwap
- type Condition
- type Context
- func (c *Context) Add(b TableBinding) Executable
- func (c *Context) Apply(cols ...ColumnBinding) SetValueStep
- func (c *Context) Batch(b *gocql.Batch) error
- func (c *Context) Bind(cols ...ColumnBinding) UniqueFetchable
- func (c *Context) Delete(cols ...Column) SelectFromStep
- func (c *Context) Dispose()
- func (c *Context) Exec(s *gocql.Session) error
- func (c *Context) Fetch(s *gocql.Session) (*gocql.Iter, error)
- func (c *Context) FetchOne(s *gocql.Session) (bool, error)
- func (c *Context) From(t Table) SelectWhereStep
- func (c *Context) Having(cond ...Condition) Executable
- func (c *Context) IfExists(cols ...ColumnBinding) CompareAndSwap
- func (c *Context) Increment(col CounterColumn, value int64) IncrementCounterStep
- func (c *Context) Limit(lim int) Fetchable
- func (c *Context) OrderBy(col ClusteredColumn) Fetchable
- func (c *Context) Prepare(s *gocql.Session) (*gocql.Query, error)
- func (c *Context) RenderCQL() (string, error)
- func (c *Context) Select(cols ...Column) SelectFromStep
- func (c *Context) SelectDistinct(col PartitionedColumn) SelectFromStep
- func (c *Context) SetArray(col ArrayColumn, value []string) SetValueStep
- func (c *Context) SetBoolean(col BooleanColumn, value bool) SetValueStep
- func (c *Context) SetBytes(col BytesColumn, value []byte) SetValueStep
- func (c *Context) SetDecimal(col DecimalColumn, value *inf.Dec) SetValueStep
- func (c *Context) SetFloat32(col Float32Column, value float32) SetValueStep
- func (c *Context) SetFloat64(col Float64Column, value float64) SetValueStep
- func (c *Context) SetInt32(col Int32Column, value int32) SetValueStep
- func (c *Context) SetInt64(col Int64Column, value int64) SetValueStep
- func (c *Context) SetMap(col MapColumn, value map[string]string) SetValueStep
- func (c *Context) SetString(col StringColumn, value string) SetValueStep
- func (c *Context) SetTimeUUID(col TimeUUIDColumn, value gocql.UUID) SetValueStep
- func (c *Context) SetTimestamp(col TimestampColumn, value time.Time) SetValueStep
- func (c *Context) Store(b TableBinding) Executable
- func (c *Context) Swap(s *gocql.Session) (bool, error)
- func (c *Context) UpdateCounter(t CounterTable) IncrementCounterStep
- func (c *Context) Upsert(u Upsertable) SetValueStep
- func (c *Context) Where(cond ...Condition) Query
- type CounterColumn
- type CounterTable
- type DecimalColumn
- type EqualityBooleanColumn
- type EqualityBytesColumn
- type EqualityDecimalColumn
- type EqualityFloat32Column
- type EqualityFloat64Column
- type EqualityInt32Column
- type EqualityInt64Column
- type EqualityStringColumn
- type EqualityTimeUUIDColumn
- type EqualityTimestampColumn
- type Executable
- type Fetchable
- type Float32Column
- type Float64Column
- type IncrementCounterStep
- type IncrementWhereStep
- type Int32Column
- type Int64Column
- type LastClusteredBooleanColumn
- type LastClusteredBytesColumn
- type LastClusteredDecimalColumn
- type LastClusteredFloat32Column
- type LastClusteredFloat64Column
- type LastClusteredInt32Column
- type LastClusteredInt64Column
- type LastClusteredStringColumn
- type LastClusteredTimeUUIDColumn
- type LastClusteredTimestampColumn
- type LastPartitionedBooleanColumn
- type LastPartitionedBytesColumn
- type LastPartitionedDecimalColumn
- type LastPartitionedFloat32Column
- type LastPartitionedFloat64Column
- type LastPartitionedInt32Column
- type LastPartitionedInt64Column
- type LastPartitionedStringColumn
- type LastPartitionedTimeUUIDColumn
- type LastPartitionedTimestampColumn
- type MapColumn
- type OperationType
- type PartitionedBooleanColumn
- type PartitionedBytesColumn
- type PartitionedColumn
- type PartitionedDecimalColumn
- type PartitionedFloat32Column
- type PartitionedFloat64Column
- type PartitionedInt32Column
- type PartitionedInt64Column
- type PartitionedStringColumn
- type PartitionedTimeUUIDColumn
- type PartitionedTimestampColumn
- type PredicateType
- type Query
- type ReadOptions
- type SelectFromStep
- type SelectSelectStep
- type SelectWhereStep
- type SetValueStep
- type StringColumn
- type Table
- type TableBinding
- type TimeUUIDColumn
- type TimestampColumn
- type UniqueFetchable
- type Upsertable
Constants ¶
This section is empty.
Variables ¶
var (
ErrCASBindings = errors.New("Invalid CAS bindings")
)
Functions ¶
func BuildStatement ¶
Types ¶
type ArrayColumn ¶
type ArrayColumn interface { Column }
type Bindable ¶
type Bindable interface {
Bind(cols ...ColumnBinding) UniqueFetchable
}
type BindingError ¶
type BindingError string
func (BindingError) Error ¶
func (m BindingError) Error() string
type BooleanColumn ¶
type BooleanColumn interface { Column To(value *bool) ColumnBinding }
type BytesColumn ¶
type BytesColumn interface { Column To(value *[]byte) ColumnBinding }
type ClusteredBooleanColumn ¶
type ClusteredBooleanColumn interface { ClusteredColumn EqualityBooleanColumn Gt(value bool) Condition Lt(value bool) Condition Ge(value bool) Condition Le(value bool) Condition }
type ClusteredBytesColumn ¶
type ClusteredBytesColumn interface { ClusteredColumn EqualityBytesColumn Gt(value []byte) Condition Lt(value []byte) Condition Ge(value []byte) Condition Le(value []byte) Condition }
type ClusteredColumn ¶
type ClusteredColumn interface { // Returns the column name that a column family is clustered with. ClusterWith() string // This specifies descending ORDER BY for the column. // If this method is not called, it an ascending order will be assumed. Desc() ClusteredColumn // Denotes whether a descending order should be applied IsDescending() bool }
ClusteredColumn is a marker interface to denote that a column is clustered.
type ClusteredDecimalColumn ¶
type ClusteredFloat32Column ¶
type ClusteredFloat32Column interface { ClusteredColumn EqualityFloat32Column Gt(value float32) Condition Lt(value float32) Condition Ge(value float32) Condition Le(value float32) Condition }
type ClusteredFloat64Column ¶
type ClusteredFloat64Column interface { ClusteredColumn EqualityFloat64Column Gt(value float64) Condition Lt(value float64) Condition Ge(value float64) Condition Le(value float64) Condition }
type ClusteredInt32Column ¶
type ClusteredInt32Column interface { ClusteredColumn EqualityInt32Column Gt(value int32) Condition Lt(value int32) Condition Ge(value int32) Condition Le(value int32) Condition }
type ClusteredInt64Column ¶
type ClusteredInt64Column interface { ClusteredColumn EqualityInt64Column Gt(value int64) Condition Lt(value int64) Condition Ge(value int64) Condition Le(value int64) Condition }
type ClusteredStringColumn ¶
type ClusteredStringColumn interface { ClusteredColumn EqualityStringColumn Gt(value string) Condition Lt(value string) Condition Ge(value string) Condition Le(value string) Condition }
type ClusteredTimeUUIDColumn ¶
type ColumnBinding ¶
type ColumnBinding struct { Column Column Value interface{} }
type Condition ¶
type Condition struct { Binding ColumnBinding Predicate PredicateType }
type Context ¶
type Context struct { Operation OperationType Table Table Columns []Column Bindings []ColumnBinding CASBindings []ColumnBinding Conditions []Condition ResultBindings map[string]ColumnBinding Debug bool ReadOptions *ReadOptions }
Context represents the state of the CQL statement that is being built by the application.
func NewContext ¶
func NewContext() *Context
NewContext creates a fresh Context instance. If you want statement debugging, set the Debug property to true
func (*Context) Add ¶
func (c *Context) Add(b TableBinding) Executable
Convenience method to generate CQL counter updates. This generates CQL SET clauses for each of the counter columns and CQL WHERE clauses for each of the key columns.
func (*Context) Apply ¶
func (c *Context) Apply(cols ...ColumnBinding) SetValueStep
Adds each column binding as a `SET col = ?` fragment in the resulting CQL
func (*Context) Bind ¶
func (c *Context) Bind(cols ...ColumnBinding) UniqueFetchable
func (*Context) Delete ¶
func (c *Context) Delete(cols ...Column) SelectFromStep
func (*Context) From ¶
func (c *Context) From(t Table) SelectWhereStep
func (*Context) Having ¶
func (c *Context) Having(cond ...Condition) Executable
func (*Context) IfExists ¶
func (c *Context) IfExists(cols ...ColumnBinding) CompareAndSwap
Adds column bindings whose values will nbe populated if a CAS operation is applied.
func (*Context) Increment ¶
func (c *Context) Increment(col CounterColumn, value int64) IncrementCounterStep
func (*Context) OrderBy ¶
func (c *Context) OrderBy(col ClusteredColumn) Fetchable
func (*Context) RenderCQL ¶
TODO Make this private, since we should be able to test against BuildStatement()
func (*Context) Select ¶
func (c *Context) Select(cols ...Column) SelectFromStep
func (*Context) SelectDistinct ¶
func (c *Context) SelectDistinct(col PartitionedColumn) SelectFromStep
func (*Context) SetArray ¶
func (c *Context) SetArray(col ArrayColumn, value []string) SetValueStep
func (*Context) SetBoolean ¶
func (c *Context) SetBoolean(col BooleanColumn, value bool) SetValueStep
func (*Context) SetBytes ¶
func (c *Context) SetBytes(col BytesColumn, value []byte) SetValueStep
func (*Context) SetDecimal ¶
func (c *Context) SetDecimal(col DecimalColumn, value *inf.Dec) SetValueStep
func (*Context) SetFloat32 ¶
func (c *Context) SetFloat32(col Float32Column, value float32) SetValueStep
func (*Context) SetFloat64 ¶
func (c *Context) SetFloat64(col Float64Column, value float64) SetValueStep
func (*Context) SetInt32 ¶
func (c *Context) SetInt32(col Int32Column, value int32) SetValueStep
func (*Context) SetInt64 ¶
func (c *Context) SetInt64(col Int64Column, value int64) SetValueStep
func (*Context) SetMap ¶
func (c *Context) SetMap(col MapColumn, value map[string]string) SetValueStep
func (*Context) SetString ¶
func (c *Context) SetString(col StringColumn, value string) SetValueStep
func (*Context) SetTimeUUID ¶
func (c *Context) SetTimeUUID(col TimeUUIDColumn, value gocql.UUID) SetValueStep
func (*Context) SetTimestamp ¶
func (c *Context) SetTimestamp(col TimestampColumn, value time.Time) SetValueStep
func (*Context) Store ¶
func (c *Context) Store(b TableBinding) Executable
func (*Context) Swap ¶
Returns true if the CAS operation was applied, false otherwise. If the operation was applied, then the result bindings will not be popluated.
func (*Context) UpdateCounter ¶
func (c *Context) UpdateCounter(t CounterTable) IncrementCounterStep
func (*Context) Upsert ¶
func (c *Context) Upsert(u Upsertable) SetValueStep
type CounterColumn ¶
type CounterColumn interface { Column CanIncrement() bool To(value *int64) ColumnBinding }
type CounterTable ¶
type DecimalColumn ¶
type DecimalColumn interface { Column To(value **inf.Dec) ColumnBinding }
type EqualityBooleanColumn ¶
type EqualityBooleanColumn interface { BooleanColumn Eq(value bool) Condition }
type EqualityBytesColumn ¶
type EqualityBytesColumn interface { BytesColumn Eq(value []byte) Condition }
type EqualityDecimalColumn ¶
type EqualityDecimalColumn interface { DecimalColumn Eq(value *inf.Dec) Condition }
type EqualityFloat32Column ¶
type EqualityFloat32Column interface { Float32Column Eq(value float32) Condition }
type EqualityFloat64Column ¶
type EqualityFloat64Column interface { Float64Column Eq(value float64) Condition }
type EqualityInt32Column ¶
type EqualityInt32Column interface { Int32Column Eq(value int32) Condition }
type EqualityInt64Column ¶
type EqualityInt64Column interface { Int64Column Eq(value int64) Condition }
type EqualityStringColumn ¶
type EqualityStringColumn interface { StringColumn Eq(value string) Condition }
type EqualityTimeUUIDColumn ¶
type EqualityTimeUUIDColumn interface { TimeUUIDColumn Eq(value gocql.UUID) Condition }
type EqualityTimestampColumn ¶
type EqualityTimestampColumn interface { TimestampColumn Eq(value time.Time) Condition }
type Executable ¶
type Float32Column ¶
type Float32Column interface { Column To(value *float32) ColumnBinding }
type Float64Column ¶
type Float64Column interface { Column To(value *float64) ColumnBinding }
type IncrementCounterStep ¶
type IncrementCounterStep interface { IncrementWhereStep Increment(col CounterColumn, value int64) IncrementCounterStep }
type IncrementWhereStep ¶
type IncrementWhereStep interface {
Having(conditions ...Condition) Executable
}
type Int32Column ¶
type Int32Column interface { Column To(value *int32) ColumnBinding }
type Int64Column ¶
type Int64Column interface { Column To(value *int64) ColumnBinding }
type LastClusteredBooleanColumn ¶
type LastClusteredBooleanColumn interface { ClusteredBooleanColumn In(value ...bool) Condition }
type LastClusteredBytesColumn ¶
type LastClusteredBytesColumn interface { ClusteredBytesColumn In(value ...[]byte) Condition }
type LastClusteredDecimalColumn ¶
type LastClusteredDecimalColumn interface { ClusteredDecimalColumn In(value ...*inf.Dec) Condition }
type LastClusteredFloat32Column ¶
type LastClusteredFloat32Column interface { ClusteredFloat32Column In(value ...float32) Condition }
type LastClusteredFloat64Column ¶
type LastClusteredFloat64Column interface { ClusteredFloat64Column In(value ...float64) Condition }
type LastClusteredInt32Column ¶
type LastClusteredInt32Column interface { ClusteredInt32Column In(value ...int32) Condition }
type LastClusteredInt64Column ¶
type LastClusteredInt64Column interface { ClusteredInt64Column In(value ...int64) Condition }
type LastClusteredStringColumn ¶
type LastClusteredStringColumn interface { ClusteredStringColumn In(value ...string) Condition }
type LastClusteredTimeUUIDColumn ¶
type LastClusteredTimeUUIDColumn interface { ClusteredTimeUUIDColumn In(value ...gocql.UUID) Condition }
type LastClusteredTimestampColumn ¶
type LastClusteredTimestampColumn interface { ClusteredTimestampColumn In(value ...time.Time) Condition }
type LastPartitionedBooleanColumn ¶
type LastPartitionedBooleanColumn interface { PartitionedBooleanColumn In(value ...bool) Condition }
type LastPartitionedBytesColumn ¶
type LastPartitionedBytesColumn interface { PartitionedBytesColumn In(value ...[]byte) Condition }
type LastPartitionedDecimalColumn ¶
type LastPartitionedDecimalColumn interface { PartitionedDecimalColumn In(value ...*inf.Dec) Condition }
type LastPartitionedFloat32Column ¶
type LastPartitionedFloat32Column interface { PartitionedFloat32Column In(value ...float32) Condition }
type LastPartitionedFloat64Column ¶
type LastPartitionedFloat64Column interface { PartitionedFloat64Column In(value ...float64) Condition }
type LastPartitionedInt32Column ¶
type LastPartitionedInt32Column interface { PartitionedInt32Column In(value ...int32) Condition }
type LastPartitionedInt64Column ¶
type LastPartitionedInt64Column interface { PartitionedInt64Column In(value ...int64) Condition }
type LastPartitionedStringColumn ¶
type LastPartitionedStringColumn interface { PartitionedStringColumn In(value ...string) Condition }
type LastPartitionedTimeUUIDColumn ¶
type LastPartitionedTimeUUIDColumn interface { PartitionedTimeUUIDColumn In(value ...gocql.UUID) Condition }
type LastPartitionedTimestampColumn ¶
type LastPartitionedTimestampColumn interface { PartitionedTimestampColumn In(value ...time.Time) Condition }
type OperationType ¶
type OperationType int
const ( None OperationType = 0 ReadOperation OperationType = 1 WriteOperation OperationType = 2 DeleteOperation OperationType = 3 CounterOperation OperationType = 4 )
type PartitionedBooleanColumn ¶
type PartitionedBooleanColumn interface { PartitionedColumn EqualityBooleanColumn }
type PartitionedBytesColumn ¶
type PartitionedBytesColumn interface { PartitionedColumn EqualityBytesColumn }
type PartitionedColumn ¶
type PartitionedColumn interface { // Returns the column definition that a column family is partitioned by. PartitionBy() Column }
PartitionedColumn is a marker interface to denote that a column is partitioned.
type PartitionedDecimalColumn ¶
type PartitionedDecimalColumn interface { PartitionedColumn EqualityDecimalColumn }
type PartitionedFloat32Column ¶
type PartitionedFloat32Column interface { PartitionedColumn EqualityFloat32Column }
type PartitionedFloat64Column ¶
type PartitionedFloat64Column interface { PartitionedColumn EqualityFloat64Column }
type PartitionedInt32Column ¶
type PartitionedInt32Column interface { PartitionedColumn EqualityInt32Column }
type PartitionedInt64Column ¶
type PartitionedInt64Column interface { PartitionedColumn EqualityInt64Column }
type PartitionedStringColumn ¶
type PartitionedStringColumn interface { PartitionedColumn EqualityStringColumn }
type PartitionedTimeUUIDColumn ¶
type PartitionedTimeUUIDColumn interface { PartitionedColumn EqualityTimeUUIDColumn }
type PartitionedTimestampColumn ¶
type PartitionedTimestampColumn interface { PartitionedColumn EqualityTimestampColumn }
type PredicateType ¶
type PredicateType int
const ( EqPredicate PredicateType = 1 GtPredicate PredicateType = 2 GePredicate PredicateType = 3 LtPredicate PredicateType = 4 LePredicate PredicateType = 5 InPredicate PredicateType = 6 )
type Query ¶
type Query interface { Executable Fetchable // OrderBy sets the ordering of the returned query OrderBy(col ClusteredColumn) Fetchable }
type SelectFromStep ¶
type SelectFromStep interface {
From(table Table) SelectWhereStep
}
type SelectSelectStep ¶
type SelectSelectStep interface { Select(cols ...Column) SelectFromStep // Builds a SELECT DISTINCT statement in CQL - this operation can only be used // with a partitioned column. SelectDistinct(col PartitionedColumn) SelectFromStep }
type SelectWhereStep ¶
type SetValueStep ¶
type SetValueStep interface { Executable SelectWhereStep Apply(cols ...ColumnBinding) SetValueStep IfExists(cols ...ColumnBinding) CompareAndSwap SetString(col StringColumn, value string) SetValueStep SetInt32(col Int32Column, value int32) SetValueStep SetInt64(col Int64Column, value int64) SetValueStep SetFloat32(col Float32Column, value float32) SetValueStep SetFloat64(col Float64Column, value float64) SetValueStep SetTimestamp(col TimestampColumn, value time.Time) SetValueStep SetTimeUUID(col TimeUUIDColumn, value gocql.UUID) SetValueStep SetBoolean(col BooleanColumn, value bool) SetValueStep SetMap(col MapColumn, value map[string]string) SetValueStep SetArray(col ArrayColumn, value []string) SetValueStep SetBytes(col BytesColumn, value []byte) SetValueStep SetDecimal(col DecimalColumn, value *inf.Dec) SetValueStep }
type StringColumn ¶
type StringColumn interface { Column To(value *string) ColumnBinding }
type TableBinding ¶
type TableBinding struct { Table Table Columns []ColumnBinding }
type TimeUUIDColumn ¶
type TimeUUIDColumn interface { Column To(value *gocql.UUID) ColumnBinding }
type TimestampColumn ¶
type TimestampColumn interface { Column To(value *time.Time) ColumnBinding }