Overview
The only thing better than a Go gRPC API would be if you guys made it easy to get the data out of protos and into local structures.
How it might look
type Person struct {
ID uuid.UUID `db:"id"`
Name string `db:"name"`
Age int64 `db:"age"`
}
// Do expensive reflection work ahead of time.
var peopleStruct = client.NewStruct(&Person{})
func main() {
c, err := client.NewStargateClientWithConn(conn)
if err != nil {
log.Fatalf("error creating Stargate client: %v", err)
}
res, err := c.ExecuteQuery(
&pb.Query{
Cql: "SELECT (id, name, age) FROM people",
},
)
if err != nil {
log.Fatalf("error executing query: %v", err)
}
// CURRENT APPROACH
rows := res.GetResultSet().GetRows()
ppl := make([]*Person, 0, len(rows))
for _, row := range rows {
vals := row.GetValues()
ppl = append(ppl, &Person{
ID: client.ToUUID(vals[0]),
Name: client.ToString(vals[1]),
Age: client.ToInt(vals[2]),
})
}
/// DESIRED APPROACH
ppl, err := peopleStruct.Scan(res) // []*People, error
if err != nil {
log.Fatalf("error scanning results to dataset: %v", err)
}
}
Helpful Links
https://github.com/huandu/go-sqlbuilder#using-struct-as-a-light-weight-orm
https://gist.github.com/sosedoff/b373623a9572cf1a992486d2d87dcd85
https://stackoverflow.com/questions/10858787/what-are-the-uses-for-tags-in-go
Overview
The only thing better than a Go gRPC API would be if you guys made it easy to get the data out of protos and into local structures.
How it might look
Helpful Links
https://github.com/huandu/go-sqlbuilder#using-struct-as-a-light-weight-orm
https://gist.github.com/sosedoff/b373623a9572cf1a992486d2d87dcd85
https://stackoverflow.com/questions/10858787/what-are-the-uses-for-tags-in-go