cql

package
v1.1.23 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cql contains functions for building CQL statements

Index

Constants

View Source
const RunIdForEmptyRun = -1

Insert - build INSERT query

Variables

This section is empty.

Functions

func RunIdSuffix added in v1.1.3

func RunIdSuffix(runId int16) string

Data/idx table name for each run needs run id as a suffix

Types

type IfNotExistsType

type IfNotExistsType int
const (
	IgnoreIfExists IfNotExistsType = 1
	ThrowIfExists  IfNotExistsType = 0
)

type QueryBuilder

type QueryBuilder struct {
	ColumnDefs           queryBuilderColumnDefs
	PartitionKeyColumns  []string
	ClusteringKeyColumns []string
	ColumnData           queryBuilderColumnData
	PreparedColumnData   queryBuilderPreparedColumnData
	Conditions           queryBuilderConditions
	IfConditions         queryBuilderConditions
	SelectLimit          int
	FormattedKeyspace    string
	OrderByColumns       []string
}

QueryBuilder - very simple cql query builder that does not require db connection

func NewQB added in v1.1.7

func NewQB() *QueryBuilder

func (*QueryBuilder) ClusteringKey

func (qb *QueryBuilder) ClusteringKey(column ...string) *QueryBuilder

func (*QueryBuilder) ColumnDef

func (qb *QueryBuilder) ColumnDef(column string, fieldType sc.TableFieldType) *QueryBuilder

func (*QueryBuilder) Cond

func (qb *QueryBuilder) Cond(column string, op string, value any) *QueryBuilder

Cond - add condition for SELECT, UPDATE or DELETE

func (*QueryBuilder) CondInInt

func (qb *QueryBuilder) CondInInt(column string, values []int64) *QueryBuilder

CondIn - add IN condition for SELECT, UPDATE or DELETE

func (*QueryBuilder) CondInInt16

func (qb *QueryBuilder) CondInInt16(column string, values []int16) *QueryBuilder

func (*QueryBuilder) CondInPrepared added in v1.1.8

func (qb *QueryBuilder) CondInPrepared(column string) *QueryBuilder

func (*QueryBuilder) CondInString

func (qb *QueryBuilder) CondInString(column string, values []string) *QueryBuilder

func (*QueryBuilder) CondPrepared added in v1.1.8

func (qb *QueryBuilder) CondPrepared(column string, op string) *QueryBuilder

func (*QueryBuilder) Create

func (qb *QueryBuilder) Create(tableName string, ifNotExists IfNotExistsType) string

func (*QueryBuilder) CreateRun

func (qb *QueryBuilder) CreateRun(tableName string, runId int16, ifNotExists IfNotExistsType) string

func (*QueryBuilder) Delete

func (qb *QueryBuilder) Delete(tableName string) string

Delete - build DELETE query

func (*QueryBuilder) DeleteRun

func (qb *QueryBuilder) DeleteRun(tableName string, runId int16) string

func (*QueryBuilder) DropKeyspace

func (qb *QueryBuilder) DropKeyspace() string

func (*QueryBuilder) If

func (qb *QueryBuilder) If(column string, op string, value any) *QueryBuilder

func (*QueryBuilder) InsertRunParams added in v1.1.7

func (qb *QueryBuilder) InsertRunParams() ([]any, error)

func (*QueryBuilder) InsertRunPreparedQuery added in v1.1.7

func (qb *QueryBuilder) InsertRunPreparedQuery(tableName string, runId int16, ifNotExists IfNotExistsType) (string, error)

func (*QueryBuilder) InsertUnpreparedQuery added in v1.1.7

func (qb *QueryBuilder) InsertUnpreparedQuery(tableName string, ifNotExists IfNotExistsType) string

func (*QueryBuilder) Keyspace

func (qb *QueryBuilder) Keyspace(keyspace string) *QueryBuilder

Keyspace - specify keyspace (optional)

func (*QueryBuilder) Limit

func (qb *QueryBuilder) Limit(limit int) *QueryBuilder

func (*QueryBuilder) OrderBy

func (qb *QueryBuilder) OrderBy(columns ...string) *QueryBuilder

func (*QueryBuilder) PartitionKey

func (qb *QueryBuilder) PartitionKey(column ...string) *QueryBuilder

func (*QueryBuilder) Select

func (qb *QueryBuilder) Select(tableName string, columns []string) string

Select - build SELECT query

func (*QueryBuilder) SelectRun

func (qb *QueryBuilder) SelectRun(tableName string, runId int16, columns []string) string

func (*QueryBuilder) Update

func (qb *QueryBuilder) Update(tableName string) string

Update - build UPDATE query

func (*QueryBuilder) UpdateRun

func (qb *QueryBuilder) UpdateRun(tableName string, runId int16) string

func (*QueryBuilder) Write

func (qb *QueryBuilder) Write(column string, value any) *QueryBuilder

Write - add a column for INSERT or UPDATE

func (*QueryBuilder) WriteForceUnquote

func (qb *QueryBuilder) WriteForceUnquote(column string, value any) *QueryBuilder

WriteForceUnquote - add a column for INSERT or UPDATE

func (*QueryBuilder) WritePreparedColumn added in v1.1.7

func (qb *QueryBuilder) WritePreparedColumn(column string) error

func (*QueryBuilder) WritePreparedValue added in v1.1.7

func (qb *QueryBuilder) WritePreparedValue(column string, value any) error

type QuotePolicyType

type QuotePolicyType int
const (
	LeaveQuoteAsIs QuotePolicyType = iota
	ForceUnquote
)

Jump to

Keyboard shortcuts

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