qb: batch builder

This commit is contained in:
Michał Matczuk
2017-08-03 17:06:03 +02:00
parent 8d47a6d133
commit 804cfad37c
3 changed files with 202 additions and 0 deletions

View File

@@ -155,6 +155,37 @@ func TestExample(t *testing.T) {
}
}
// Batch
{
i := qb.Insert("gocqlx_test.person").Columns("first_name", "last_name", "email")
stmt, names := qb.Batch().
Add("a.", i).
Add("b.", i).
ToCql()
q := gocqlx.Query(session.Query(stmt), names)
b := struct {
A Person
B Person
}{
A: Person{
"Ian",
"Citizen",
[]string{"ian.citzen@gocqlx_test.com"},
},
B: Person{
"Igy",
"Citizen",
[]string{"igy.citzen@gocqlx_test.com"},
},
}
if err := q.BindStruct(&b).Exec(); err != nil {
t.Fatal(err)
}
}
// Select
{
stmt, names := qb.Select("gocqlx_test.person").Where(qb.In("first_name")).ToCql()