qb: Added shortcuts to Queryx
It allows to write shorter and more straightforward code.
Instead writing:
```
session.Query(qb.Select("cluster").Columns("id").ToCql())
```
you can write:
```
qb.Select("cluster").Columns("id").Query(session)
```
This commit is contained in:
committed by
Michal Jan Matczuk
parent
564db08698
commit
4f4f94e2e6
@@ -10,6 +10,8 @@ package qb
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/scylladb/gocqlx/v2"
|
||||
)
|
||||
|
||||
// Order specifies sorting order.
|
||||
@@ -118,6 +120,11 @@ func (b *SelectBuilder) ToCql() (stmt string, names []string) {
|
||||
return
|
||||
}
|
||||
|
||||
// Query returns query built on top of current SelectBuilder state.
|
||||
func (b *SelectBuilder) Query(session gocqlx.Session) *gocqlx.Queryx {
|
||||
return session.Query(b.ToCql())
|
||||
}
|
||||
|
||||
// From sets the table to be selected from.
|
||||
func (b *SelectBuilder) From(table string) *SelectBuilder {
|
||||
b.table = table
|
||||
|
||||
Reference in New Issue
Block a user