BindStructMap

This commit is contained in:
Michał Matczuk
2017-08-01 13:29:52 +02:00
parent 906f9433fe
commit 711e3369d6
4 changed files with 71 additions and 13 deletions

View File

@@ -4,6 +4,7 @@ package gocqlx_test
import (
"testing"
"time"
"github.com/gocql/gocql"
"github.com/scylladb/gocqlx"
@@ -134,6 +135,17 @@ func TestExample(t *testing.T) {
mustExec(q.Query)
}
// Insert with TTL
{
q := Query(qb.Insert("gocqlx_test.person").Columns("first_name", "last_name", "email").TTL().ToCql())
if err := q.BindStructMap(p, map[string]interface{}{
"_ttl": qb.TTL(86400 * time.Second),
}); err != nil {
t.Fatal("bind:", err)
}
mustExec(q.Query)
}
// Update
{
p.Email = append(p.Email, "patricia1.citzen@gocqlx_test.com")