Merge pull request #3 from hailocab/upstream-merge
Upstream merge Add Session wrapper With this patch we can now use gocqlx like: ``` session.Query(`SELECT * FROM struct_table`, nil).Get(&v) ``` instead of (old format): ``` gocqlx.Query(session.Query(`SELECT * FROM struct_table`), nil).Get(&v) ``` Signed-off-by: Michał Matczuk <michal@scylladb.com>
This commit is contained in:
committed by
Michal Jan Matczuk
parent
ab279e68ed
commit
95d96fa939
17
doc_test.go
17
doc_test.go
@@ -1,9 +1,26 @@
|
||||
// Copyright (C) 2017 ScyllaDB
|
||||
// Use of this source code is governed by a ALv2-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package gocqlx_test
|
||||
|
||||
import (
|
||||
"github.com/gocql/gocql"
|
||||
"github.com/scylladb/gocqlx"
|
||||
"github.com/scylladb/gocqlx/qb"
|
||||
)
|
||||
|
||||
func ExampleSession() {
|
||||
cluster := gocql.NewCluster("host")
|
||||
session, err := gocqlx.WrapSession(cluster.CreateSession())
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
builder := qb.Select("foo")
|
||||
session.Query(builder.ToCql())
|
||||
}
|
||||
|
||||
func ExampleUDT() {
|
||||
// Just add gocqlx.UDT to a type, no need to implement marshalling functions
|
||||
type FullName struct {
|
||||
|
||||
Reference in New Issue
Block a user