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 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) RenderCQL() (string, error)
- func (c *Context) Select(cols ...Column) 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 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 PartitionedDecimalColumn
- type PartitionedFloat32Column
- type PartitionedFloat64Column
- type PartitionedInt32Column
- type PartitionedInt64Column
- type PartitionedStringColumn
- type PartitionedTimeUUIDColumn
- type PartitionedTimestampColumn
- type PredicateType
- type Query
- 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 ClusteredBytesColumn ¶
type ClusteredDecimalColumn ¶
type ClusteredFloat32Column ¶
type ClusteredFloat64Column ¶
type ClusteredInt32Column ¶
type ClusteredInt64Column ¶
type ClusteredStringColumn ¶
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 }
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) 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) 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 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 { BooleanColumn Eq(value bool) Condition }
type PartitionedBytesColumn ¶
type PartitionedBytesColumn interface { BytesColumn Eq(value []byte) Condition }
type PartitionedDecimalColumn ¶
type PartitionedDecimalColumn interface { DecimalColumn Eq(value *inf.Dec) Condition }
type PartitionedFloat32Column ¶
type PartitionedFloat32Column interface { Float32Column Eq(value float32) Condition }
type PartitionedFloat64Column ¶
type PartitionedFloat64Column interface { Float64Column Eq(value float64) Condition }
type PartitionedInt32Column ¶
type PartitionedInt32Column interface { Int32Column Eq(value int32) Condition }
type PartitionedInt64Column ¶
type PartitionedInt64Column interface { Int64Column Eq(value int64) Condition }
type PartitionedStringColumn ¶
type PartitionedStringColumn interface { StringColumn Eq(value string) Condition }
type PartitionedTimeUUIDColumn ¶
type PartitionedTimeUUIDColumn interface { TimeUUIDColumn Eq(value gocql.UUID) Condition }
type PartitionedTimestampColumn ¶
type PartitionedTimestampColumn interface { TimestampColumn Eq(value time.Time) Condition }
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 Bindable }
type SelectFromStep ¶
type SelectFromStep interface {
From(table Table) SelectWhereStep
}
type SelectSelectStep ¶
type SelectSelectStep interface {
Select(cols ...Column) 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 }