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:
Maciej Zimnoch
2020-06-17 16:36:24 +02:00
committed by Michal Jan Matczuk
parent 564db08698
commit 4f4f94e2e6
5 changed files with 35 additions and 0 deletions

View File

@@ -10,6 +10,8 @@ package qb
import (
"bytes"
"time"
"github.com/scylladb/gocqlx/v2"
)
// DeleteBuilder builds CQL DELETE statements.
@@ -54,6 +56,11 @@ func (b *DeleteBuilder) ToCql() (stmt string, names []string) {
return
}
// Query returns query built on top of current DeleteBuilder state.
func (b *DeleteBuilder) Query(session gocqlx.Session) *gocqlx.Queryx {
return session.Query(b.ToCql())
}
// From sets the table to be deleted from.
func (b *DeleteBuilder) From(table string) *DeleteBuilder {
b.table = table