We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any interface out there to implement it for our types in order to achieve custom bindings ?
//"CREATE TABLE testKS.Foos (id uuid PRIMARY KEY, user_id text, bars map<text,int>)" var tableName = "testKS.Foos" type Foo struct { ID gocql.UUID `db:"id"` UserID string `db:"user_id"` Bars []Bar `db:"bars"` } type Bar struct { Key string `db:"key"` Value int `db:"value"` } func FetchFoo(session *gocql.Session) { qry, _ := qb.Select(tableName).ToCql() var items []*Foo err := gocqlx.Select(&items, session.Query(qry)) if err != nil { log.Fatal(err) // can not marshal []Bar into map(varchar, int) } return items } func InsertFoo(session *gocql.Session, foo Foo) { qry, names := qb.Insert(tableName). Columns("id", "user_id", "bars"). ToCql() err := gocqlx.Query(session.Query(qry), names).BindStruct(&foo).ExecRelease() if err != nil { log.Fatal(err) // can not unmarshal map(varchar, int) into *[]Bar } }
The text was updated successfully, but these errors were encountered:
Hi @patachi, this is more of a question about gocql, I'd suggest adding type BarSlice []Bar and implementing gocql.Marshaller and gocql.Unmarshaller interfaces, see for example https://github.com/scylladb/gocqlx/blob/master/iterx_test.go#L27.
type BarSlice []Bar
gocql.Marshaller
gocql.Unmarshaller
Sorry, something went wrong.
No branches or pull requests
Is there any interface out there to implement it for our types in order to achieve custom bindings ?
The text was updated successfully, but these errors were encountered: