forked from scylladb/gocqlx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc_test.go
44 lines (37 loc) · 851 Bytes
/
doc_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// 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/v2"
"github.com/scylladb/gocqlx/v2/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 {
gocqlx.UDT
FirstName string
LastName string
}
}
func ExampleUDT_wraper() {
type FullName struct {
FirstName string
LastName string
}
// Create new UDT wrapper type
type FullNameUDT struct {
gocqlx.UDT
*FullName
}
}