qb: json support
This commit is contained in:
committed by
Michal Matczuk
parent
eadf9b5427
commit
31ae81aba6
12
qb/select.go
12
qb/select.go
@@ -40,6 +40,7 @@ type SelectBuilder struct {
|
||||
limit uint
|
||||
limitPerPartition uint
|
||||
allowFiltering bool
|
||||
json bool
|
||||
}
|
||||
|
||||
// Select returns a new SelectBuilder with the given table name.
|
||||
@@ -54,6 +55,11 @@ func (b *SelectBuilder) ToCql() (stmt string, names []string) {
|
||||
cql := bytes.Buffer{}
|
||||
|
||||
cql.WriteString("SELECT ")
|
||||
|
||||
if b.json {
|
||||
cql.WriteString("JSON ")
|
||||
}
|
||||
|
||||
switch {
|
||||
case len(b.distinct) > 0:
|
||||
cql.WriteString("DISTINCT ")
|
||||
@@ -113,6 +119,12 @@ func (b *SelectBuilder) From(table string) *SelectBuilder {
|
||||
return b
|
||||
}
|
||||
|
||||
// Json sets the clause of the query.
|
||||
func (b *SelectBuilder) Json() *SelectBuilder {
|
||||
b.json = true
|
||||
return b
|
||||
}
|
||||
|
||||
// Columns adds result columns to the query.
|
||||
func (b *SelectBuilder) Columns(columns ...string) *SelectBuilder {
|
||||
b.columns = append(b.columns, columns...)
|
||||
|
||||
Reference in New Issue
Block a user