Michał Matczuk 41bb8def2a qb: doc
2017-07-31 15:30:26 +02:00
2017-07-31 15:30:26 +02:00
2017-07-24 13:00:21 +02:00
2017-07-24 13:21:29 +02:00
boo
2017-07-25 08:25:58 +02:00
2017-07-31 15:30:26 +02:00
2017-07-31 15:30:26 +02:00
2017-07-25 08:25:58 +02:00
2017-07-25 11:09:41 +02:00
2017-07-25 08:34:43 +02:00
2017-07-25 14:12:25 +02:00
2017-07-26 13:37:45 +02:00
2017-07-25 08:34:43 +02:00
2017-07-31 15:30:26 +02:00
2017-07-31 15:30:26 +02:00
2017-07-31 15:30:26 +02:00

gocqlx GoDoc Go Report Card Build Status

Package gocqlx is a Scylla / Cassandra productivity toolkit for gocql, it's similar to what sqlx is to database/sql.

It contains wrappers over gocql types that provide convenience methods which are useful in the development of database driven applications. Under the hood it uses sqlx/reflectx package so sqlx models will also work with gocqlx.

Installation

go get github.com/scylladb/gocqlx

Features

Fast, boilerplate free and flexible SELECTS, INSERTS, UPDATES and DELETES.

type Person struct {
	FirstName string  // no need to add `db:"first_name"` etc.
	LastName  string
	Email     []string
}

p := &Person{
	"Patricia",
	"Citizen",
	[]string{"patricia.citzen@gocqlx_test.com"},
}

// Insert
{
	q := Query(qb.Insert("person").Columns("first_name", "last_name", "email").ToCql())
	if err := q.BindStruct(p); err != nil {
		t.Fatal("bind:", err)
	}
	mustExec(q.Query)
}

// Update
{
	p.Email = append(p.Email, "patricia1.citzen@gocqlx_test.com")

	q := Query(qb.Update("person").Set("email").Where(qb.Eq("first_name"), qb.Eq("last_name")).ToCql())
	if err := q.BindStruct(p); err != nil {
		t.Fatal("bind:", err)
	}
	mustExec(q.Query)
}

// Select
{
	q := Query(qb.Select("person").Where(qb.In("first_name")).ToCql())
	m := map[string]interface{}{
		"first_name": []string{"Patricia", "John"},
	}
	if err := q.BindMap(m); err != nil {
		t.Fatal("bind:", err)
	}

	var people []Person
	if err := gocqlx.Select(&people, q.Query); err != nil {
		t.Fatal(err)
	}
	t.Log(people)

	// [{Patricia Citizen [patricia.citzen@gocqlx_test.com patricia1.citzen@gocqlx_test.com]} {John Doe [johndoeDNE@gmail.net]}]
}

For more details see example test.

Description
No description provided
Readme 667 KiB
1.0.0 Latest
2025-11-20 16:10:32 +01:00
Languages
Go 97.2%
Makefile 2.8%