query: Query return ptr

This commit is contained in:
Michał Matczuk
2017-08-24 11:54:41 +02:00
parent 73666e5f16
commit 1da2c19fe8
3 changed files with 93 additions and 82 deletions

View File

@@ -84,8 +84,8 @@ type Queryx struct {
}
// Query creates a new Queryx from gocql.Query using a default mapper.
func Query(q *gocql.Query, names []string) Queryx {
return Queryx{
func Query(q *gocql.Query, names []string) *Queryx {
return &Queryx{
Query: q,
Names: names,
Mapper: DefaultMapper,
@@ -192,13 +192,3 @@ func (q *Queryx) ExecRelease() error {
defer q.Release()
return q.Exec()
}
// QueryFunc creates Queryx from qb.Builder.ToCql() output.
type QueryFunc func(stmt string, names []string) Queryx
// SessionQuery creates QueryFunc that's session aware.
func SessionQuery(session *gocql.Session) QueryFunc {
return func(stmt string, names []string) Queryx {
return Query(session.Query(stmt), names)
}
}