Documentation
¶
Overview ¶
Package cuckle builds Cassandra CQL query strings.
Index ¶
- func QueryAggregateCreate(keyspace, aggregate, stateFunc Identifier, parameters []Type, stateType Type, ...) string
- func QueryAggregateDrop(keyspace, aggregate Identifier, parameters []Type, o ...Option) string
- func QueryBatch(counter bool, timestamp int64, queries []string) string
- func QueryFunctionCreate(keyspace, function Identifier, parameters []Type, null bool, returns Type, ...) string
- func QueryFunctionDrop(keyspace, function Identifier, parameters []Type, o ...Option) string
- func QueryIndexCreate(keyspace, table, column Identifier, o ...Option) string
- func QueryIndexDrop(keyspace, index Identifier, o ...Option) string
- func QueryKeyspaceAlter(keyspace Identifier, properties map[Identifier]Term) string
- func QueryKeyspaceCreate(keyspace Identifier, properties map[Identifier]Term, o ...Option) string
- func QueryKeyspaceDrop(keyspace Identifier, o ...Option) string
- func QueryRowDelete(keyspace, table Identifier, where []Relation, o ...Option) string
- func QueryRowInsert(keyspace, table Identifier, columns []Identifier, values []Term, json string, ...) string
- func QueryRowSelect(keyspace, table Identifier, s []Selector, o ...Option) string
- func QueryRowUpdate(keyspace, table Identifier, assign, where []Relation, o ...Option) string
- func QueryTableAlter(keyspace, table Identifier, properties map[Identifier]Term, o ...Option) string
- func QueryTableColumnAdd(keyspace, table, column Identifier, data Type) string
- func QueryTableColumnAlter(keyspace, table, column Identifier, data Type) string
- func QueryTableColumnDrop(keyspace, table, column Identifier) string
- func QueryTableCreate(keyspace, table Identifier, columns map[Identifier]Type, ...) string
- func QueryTableDrop(keyspace, table Identifier, o ...Option) string
- func QueryTableTruncate(keyspace, table Identifier) string
- func QueryTriggerCreate(keyspace, table, trigger Identifier, class string, o ...Option) string
- func QueryTriggerDrop(keyspace, table Identifier, o ...Option) string
- func QueryTypeCreate(keyspace, type_ Identifier, fields map[Identifier]Type, o ...Option) string
- func QueryTypeDrop(keyspace, type_ Identifier, o ...Option) string
- func QueryTypeFieldAdd(keyspace, type_, field Identifier, data Type) string
- func QueryTypeFieldAlter(keyspace, type_, field Identifier, data Type) string
- func QueryTypeFieldRename(keyspace, type_, renames map[Identifier]Identifier) string
- func QueryViewAlter(keyspace, view Identifier, o ...Option) string
- func QueryViewCreate(keyspace, table, view Identifier, s []Selector, ...) string
- func QueryViewDrop(keyspace, table Identifier, o ...Option) string
- type Constant
- type Identifier
- type Operator
- type Option
- func OptionAliases(aliases map[Identifier]Identifier) Option
- func OptionClass(class string) Option
- func OptionClassOptions(options map[Term]Term) Option
- func OptionFinalFunc(finalFunc Identifier) Option
- func OptionIf(r ...Relation) Option
- func OptionInitCond(initCond Term) Option
- func OptionLimit(limit int) Option
- func OptionName(name Identifier) Option
- func OptionOrder(i []Identifier, o []Order) Option
- func OptionProperties(options map[Identifier]Term) Option
- func OptionSelectors(s ...Selector) Option
- func OptionTTL(ttl int64) Option
- func OptionTimestamp(timestamp int64) Option
- func OptionWhere(r ...Relation) Option
- type Order
- type Relation
- type Selector
- func SelectorAlias(s Selector, alias Identifier) Selector
- func SelectorFunc(function Identifier, arguments ...Selector) Selector
- func SelectorIdentifier(column Identifier) Selector
- func SelectorIndex(column Identifier, index Term) Selector
- func SelectorTTL(i Identifier) Selector
- func SelectorWriteTime(i Identifier) Selector
- type Term
- func TermConstant(c Constant) Term
- func TermFunc(function Identifier, arguments ...Term) Term
- func TermIdentifier(i Identifier) Term
- func TermIndex(i Identifier, t Term) Term
- func TermList(t ...Term) Term
- func TermMap(m map[Term]Term) Term
- func TermRelation(r Relation) Term
- func TermSet(t ...Term) Term
- func TermTuple(t ...Term) Term
- type Type
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QueryAggregateCreate ¶
func QueryAggregateCreate(keyspace, aggregate, stateFunc Identifier, parameters []Type, stateType Type, o ...Option) string
func QueryAggregateDrop ¶
func QueryAggregateDrop(keyspace, aggregate Identifier, parameters []Type, o ...Option) string
func QueryFunctionCreate ¶
func QueryFunctionDrop ¶
func QueryFunctionDrop(keyspace, function Identifier, parameters []Type, o ...Option) string
func QueryIndexCreate ¶
func QueryIndexCreate(keyspace, table, column Identifier, o ...Option) string
func QueryIndexDrop ¶
func QueryIndexDrop(keyspace, index Identifier, o ...Option) string
func QueryKeyspaceAlter ¶
func QueryKeyspaceAlter(keyspace Identifier, properties map[Identifier]Term) string
func QueryKeyspaceCreate ¶
func QueryKeyspaceCreate(keyspace Identifier, properties map[Identifier]Term, o ...Option) string
func QueryKeyspaceDrop ¶
func QueryKeyspaceDrop(keyspace Identifier, o ...Option) string
func QueryRowDelete ¶
func QueryRowDelete(keyspace, table Identifier, where []Relation, o ...Option) string
func QueryRowInsert ¶
func QueryRowInsert(keyspace, table Identifier, columns []Identifier, values []Term, json string, o ...Option) string
func QueryRowSelect ¶
func QueryRowSelect(keyspace, table Identifier, s []Selector, o ...Option) string
func QueryRowUpdate ¶
func QueryRowUpdate(keyspace, table Identifier, assign, where []Relation, o ...Option) string
func QueryTableAlter ¶
func QueryTableAlter(keyspace, table Identifier, properties map[Identifier]Term, o ...Option) string
func QueryTableColumnAdd ¶
func QueryTableColumnAdd(keyspace, table, column Identifier, data Type) string
func QueryTableColumnAlter ¶
func QueryTableColumnAlter(keyspace, table, column Identifier, data Type) string
func QueryTableColumnDrop ¶
func QueryTableColumnDrop(keyspace, table, column Identifier) string
func QueryTableCreate ¶
func QueryTableCreate(keyspace, table Identifier, columns map[Identifier]Type, static map[Identifier]struct{}, partition, cluster []Identifier, o ...Option) string
func QueryTableDrop ¶
func QueryTableDrop(keyspace, table Identifier, o ...Option) string
func QueryTableTruncate ¶
func QueryTableTruncate(keyspace, table Identifier) string
func QueryTriggerCreate ¶
func QueryTriggerCreate(keyspace, table, trigger Identifier, class string, o ...Option) string
func QueryTriggerDrop ¶
func QueryTriggerDrop(keyspace, table Identifier, o ...Option) string
func QueryTypeCreate ¶
func QueryTypeCreate(keyspace, type_ Identifier, fields map[Identifier]Type, o ...Option) string
func QueryTypeDrop ¶
func QueryTypeDrop(keyspace, type_ Identifier, o ...Option) string
func QueryTypeFieldAdd ¶
func QueryTypeFieldAdd(keyspace, type_, field Identifier, data Type) string
func QueryTypeFieldAlter ¶
func QueryTypeFieldAlter(keyspace, type_, field Identifier, data Type) string
func QueryTypeFieldRename ¶
func QueryTypeFieldRename(keyspace, type_, renames map[Identifier]Identifier) string
func QueryViewAlter ¶
func QueryViewAlter(keyspace, view Identifier, o ...Option) string
func QueryViewCreate ¶
func QueryViewCreate(keyspace, table, view Identifier, s []Selector, partition, cluster []Identifier, o ...Option) string
func QueryViewDrop ¶
func QueryViewDrop(keyspace, table Identifier, o ...Option) string
Types ¶
type Constant ¶
type Constant string
Constant is a scalar literal.
func ConstantBoolean ¶
ConstantBoolean returns a Constant for b.
func ConstantHex ¶
ConstantHex returns a Constant for b prefixed by 0x. Two characters represent each byte.
func ConstantInteger ¶
ConstantInteger returns a Constant for i.
func ConstantString ¶
ConstantString returns a Constant for s.
func ConstantStringEscaped ¶
ConstantStringEscaped returns a Constant for s.
func ConstantUUID ¶
ConstantUUID returns a Constant for uuid.
type Identifier ¶
type Identifier string
Identifier is a double-quoted identifier.
const ( FuncAvg Identifier = "avg" FuncDateOf Identifier = "dateof" FuncFromJSON Identifier = "fromjson" FuncMax Identifier = "max" FuncMaxTimeuuid Identifier = "maxtimeuuid" FuncMin Identifier = "min" FuncMinTimeuuid Identifier = "mintimeuuid" FuncNow Identifier = "now" FuncSum Identifier = "sum" FuncToDate Identifier = "todate" FuncToJSON Identifier = "tojson" FuncToken Identifier = "token" FuncToTimestamp Identifier = "totimestamp" FuncToUnixTimestamp Identifier = "tounixtimestamp" FuncUnixTimestampOf Identifier = "unixtimestampof" FuncUUID Identifier = "uuid" )
General functions.
const ( FuncBlobToASCII Identifier = "blobtoascii" FuncBlobToBigInt Identifier = "blobtobigint" FuncBlobToBoolean Identifier = "blobtoboolean" FuncBlobToCounter Identifier = "blobtocounter" FuncBlobToDate Identifier = "blobtodate" FuncBlobToDecimal Identifier = "blobtodecimal" FuncBlobToDouble Identifier = "blobtodouble" FuncBlobToFloat Identifier = "blobtofloat" FuncBlobToInet Identifier = "blobtoinet" FuncBlobToInt Identifier = "blobtoint" FuncBlobToSmallInt Identifier = "blobtosmallint" FuncBlobToText Identifier = "blobtotext" FuncBlobToTime Identifier = "blobtotime" FuncBlobToTimeUUID Identifier = "blobtotimeuuid" FuncBlobToTimestamp Identifier = "blobtotimestamp" FuncBlobToTinyInt Identifier = "blobtotinyint" FuncBlobToUUID Identifier = "blobtouuid" FuncBlobToVarChar Identifier = "blobtovarchar" FuncBlobToVarInt Identifier = "blobtovarint" )
Functions that convert from blob to other types.
const ( FuncASCIIToBlob Identifier = "asciitoblob" FuncBigIntToBlob Identifier = "biginttoblob" FuncBooleanToBlob Identifier = "booleantoblob" FuncCounterToBlob Identifier = "countertoblob" FuncDateToBlob Identifier = "datetoblob" FuncDecimalToBlob Identifier = "decimaltoblob" FuncDoubleToBlob Identifier = "doubletoblob" FuncFloatToBlob Identifier = "floattoblob" FuncInetToBlob Identifier = "inettoblob" FuncIntToBlob Identifier = "inttoblob" FuncSmallIntToBlob Identifier = "smallinttoblob" FuncTextToBlob Identifier = "texttoblob" FuncTimeToBlob Identifier = "timetoblob" FuncTimeUUIDToBlob Identifier = "timeuuidtoblob" FuncTimestampToBlob Identifier = "timestamptoblob" FuncTinyIntToBlob Identifier = "tinyinttoblob" FuncUUIDToBlob Identifier = "uuidtoblob" FuncVarCharToBlob Identifier = "varchartoblob" FuncVarIntToBlob Identifier = "varinttoblob" )
Functions that convert from other types to blob.
const ( KeyspaceDurableWrites Identifier = "durable_writes" KeyspaceReplication Identifier = "replication" )
Keyspace properties.
const ( TableBaseTimeSeconds Identifier = "base_time_seconds" TableBloomFilterFPChance Identifier = "bloom_filter_fp_chance" TableBucketHigh Identifier = "bucket_high" TableBucketLow Identifier = "bucket_low" TableCRCCheckChance Identifier = "crc_check_chance" TableCaching Identifier = "caching" TableChunkLengthInKB Identifier = "chunk_length_in_kb" TableClass Identifier = "class" TableComment Identifier = "comment" TableCompaction Identifier = "compaction" TableCompression Identifier = "compression" TableDCLocalReadRepairChance Identifier = "dclocal_read_repair_chance" TableDefaultTimeToLive Identifier = "default_time_to_live" TableEnabled Identifier = "enabled" TableGCGraceSeconds Identifier = "gc_grace_seconds" TableKeys Identifier = "keys" TableMaxSSTableAgeDays Identifier = "max_sstable_age_days" TableMaxThreshold Identifier = "max_threshold" TableMinSSTableSize Identifier = "min_sstable_size" TableMinThreshold Identifier = "min_threshold" TableReadRepairChance Identifier = "read_repair_chance" TableRowsPerPartition Identifier = "rows_per_partition" TableSSTableSizeInMB Identifier = "sstable_size_in_mb" TableTimestampResolution Identifier = "timestamp_resolution" TableTombstoneCompactionInternal Identifier = "tombstone_compaction_interval" TableTombstoneThreshold Identifier = "tombstone_threshold" TableUncheckedTombstoneCompaction Identifier = "unchecked_tombstone_compaction" )
Table properties.
func (Identifier) String ¶
func (i Identifier) String() string
type Operator ¶
type Operator string
const ( OperatorAdd Operator = "+" OperatorContains Operator = "contains" OperatorContainsKey Operator = "contains key" OperatorEqual Operator = "=" OperatorGreater Operator = ">" OperatorGreaterEqual Operator = ">=" OperatorIn Operator = "in" OperatorLess Operator = "<" OperatorLessEqual Operator = "<=" OperatorNotEqual Operator = "!=" OperatorSubtract Operator = "-" )
type Option ¶
type Option map[option]interface{}
Option stores optional query parameters.
var ( // OptionAllowFiltering allows filtering result rows. OptionAllowFiltering Option = Option{/* contains filtered or unexported fields */} // OptionClusteringOrder is the ordering of rows on disk. OptionClusteringOrder Option = Option{/* contains filtered or unexported fields */} // OptionCompactStorage uses a more compact but less flexible layout for tables. OptionCompactStorage Option = Option{/* contains filtered or unexported fields */} // OptionDistinct removes rows with duplicate partition keys from result rows. OptionDistinct Option = Option{/* contains filtered or unexported fields */} // OptionIfExists does not execute create queries for existing primary keys. OptionIfExists Option = Option{/* contains filtered or unexported fields */} // OptionIfNotExists does not execute drop queries for invalid primary keys. OptionIfNotExists Option = Option{/* contains filtered or unexported fields */} // OptionIndexKeys creates an index on map keys. OptionIndexKeys Option = Option{/* contains filtered or unexported fields */} // OptionJSON uses JSON for insert and select queries. OptionJSON Option = Option{/* contains filtered or unexported fields */} // OptionReplace replaces any existing aggregates and functions. OptionReplace Option = Option{/* contains filtered or unexported fields */} )
Options with no parameters.
func OptionAliases ¶
func OptionAliases(aliases map[Identifier]Identifier) Option
OptionAliases returns an Option for column aliases.
func OptionClass ¶
OptionClass returns an Option for a custom index class.
func OptionClassOptions ¶
OptionClassOptions returns an Option for custom index class options.
func OptionFinalFunc ¶
func OptionFinalFunc(finalFunc Identifier) Option
OptionFinalFunc returns an Option for an aggregate final function.
func OptionInitCond ¶
OptionInitCond returns an Option for an aggregate initial condition.
func OptionLimit ¶
OptionLimit returns an Option for a result row limit.
func OptionOrder ¶
func OptionOrder(i []Identifier, o []Order) Option
OptionOrder returns an Option for ordering result rows by columns and directions. There must be the same number of columns and directions.
func OptionProperties ¶
func OptionProperties(options map[Identifier]Term) Option
OptionProperties returns an Option for mapping property keys to values.
func OptionSelectors ¶
OptionSelectors returns an Option for selecting column values.
func OptionTimestamp ¶
OptionTimestamp returns an Option for insert and update timestamps.
func OptionWhere ¶
OptionWhere returns an Option for conditions.
type Relation ¶
type Relation string
Relation is an infix operation with an operator and two operands.
func NewRelation ¶
NewRelation returns a new Relation for left, o, and right.
type Selector ¶
type Selector string
Selector selects the result row values.
const ( // SelectorAll selects all columns. SelectorAll Selector = "*" // SelectorCount selects the count of all result rows. SelectorCount Selector = "count(*)" )
Simple selectors.
func SelectorAlias ¶
func SelectorAlias(s Selector, alias Identifier) Selector
SelectorAlias returns a Selector for aliasing a Selector.
func SelectorFunc ¶
func SelectorFunc(function Identifier, arguments ...Selector) Selector
SelectorFunc returns a Selector for calling a function with argumnets.
func SelectorIdentifier ¶
func SelectorIdentifier(column Identifier) Selector
SelectorIdentifier returns a Selector for a column.
func SelectorIndex ¶
func SelectorIndex(column Identifier, index Term) Selector
SelectorIndex returns a Selector for indexing a column.
func SelectorTTL ¶
func SelectorTTL(i Identifier) Selector
SelectorTTL returns a Selector for the time-to-live of a column.
func SelectorWriteTime ¶
func SelectorWriteTime(i Identifier) Selector
SelectorWriteTime returns a Selector for the write time of a column.
type Term ¶
type Term string
Term is a value.
func TermFunc ¶
func TermFunc(function Identifier, arguments ...Term) Term
TermFunc returns a Term for calling a function with arguments.
func TermIdentifier ¶
func TermIdentifier(i Identifier) Term
TermIdentifier returns a Term for an Identifier.
func TermIndex ¶
func TermIndex(i Identifier, t Term) Term
TermIndex returns a Term for indexing a column.
type Type ¶
type Type string
Type is a type.
const ( TypeAscii Type = "ascii" TypeBigint Type = "bigint" TypeBlob Type = "blob" TypeBoolean Type = "boolean" TypeCounter Type = "counter" TypeDate Type = "date" TypeDecimal Type = "decimal" TypeDouble Type = "double" TypeFloat Type = "float" TypeInet Type = "inet" TypeInt Type = "int" TypeSmallint Type = "smallint" TypeText Type = "text" TypeTime Type = "time" TypeTimestamp Type = "timestamp" TypeTimeuuid Type = "timeuuid" TypeTinyint Type = "tinyint" TypeUuid Type = "uuid" TypeVarchar Type = "varchar" TypeVarint Type = "varint" )
Built-in types.