Comments (6)
Are you asking specifically about Go? Have you looked at the examples @ https://github.com/scylladb/gocql (root dir, there are several ones) ?
from gocqlx.
Are you asking specifically about Go? Have you looked at the examples @ https://github.com/scylladb/gocql (root dir, there are several ones) ?
Or the examples in this repo?
from gocqlx.
Are you asking specifically about Go? Have you looked at the examples @ https://github.com/scylladb/gocql (root dir, there are several ones) ?
gocqlx. I've used gocql a lot; I'd like to handwrite fewer queries. I see lots of examples in the tests, but it's taking me a long time to piece them together into a select * from users where email='[email protected]'
statement - and after that where user_id={uuid_var}
. I see strings being passed around, and byte arrays being used instead of gocql.UUID, so I expect that to take a bit of time to handle as well.
- I added some lines to demonstrate initialization of Csm in my code
from gocqlx.
Great! I was able to figure my mistakes from this issue: #109
My solution:
stmt, names := qb.Select("aim.surfers").Where(qb.Eq("surfer_uuid")).Limit(1).ToCql()
res := uy.Csm.Query(stmt, names).Bind(in.SurferUuid)
if err := res.GetRelease(&out); err != nil {
uy.Error(err)
}
I appreciate the library greatly. My thoughts as a newcomer: the docline for GetRelease did not convey what it does to me; maybe it's using driver-side terminology.
GetRelease calls Get and releases the query, a released query cannot be reused.
Also Queryx.Names is a similar example:
Queryx is a wrapper around gocql.Query which adds struct binding capabilities.
from gocqlx.
@avelanarius - anything we can do to improve the documentation around GetRelease() ?
from gocqlx.
Just to share - my original interpretations that tripped me up:
- I thought the
names
variable was used to bind values to a query. Because the querybuilder returns it, it seemed like it was used to build the query - you can see I was trying to cram prepared query parameters intonames
lol - I thought
Bind()
was used to bind values to the output struct (as opposed to binding to the query). The doc forBind()
seems fine, but I never thought to look it up. I assumed it was a wrapper forgocql.Iter.MapScan/StructScan
- I assumed
GetRelease()
was a simple cleanup function. What tripped me up here is the doc forGet()
saysscans first row into a destination
, and it simply didn't click in my brain thatdestination
meantstruct to unpack the query result
. The language was too abstracted for me. It does mentionIter.StructScan
, but it just didn't click for me; it's been a long time since I've had to deal withIter
directly
I'm still not sure what names
does - at this point I guess BindMap()
uses it, but I'm not sure if anything else does. There were no compiler errors since many functions accept ...string
or ...interface{}
(probably unavoidable)
imo, an examples.go
file with some comments might be best/simplest. Compile time feedback could be given if it's possible to create a type Names ...
from gocqlx.
Related Issues (20)
- Health check for cassandra HOT 1
- Issue with CAS operations HOT 6
- Upgrade to Go 1.18 HOT 7
- Fix linter in GH action HOT 4
- Fix linter errors HOT 1
- Select query with IN and Boolean List does not return row HOT 4
- migrate: detach context from parent context cancelation HOT 1
- expected 1 column in result while scanning scannable type ptr but got 9 when using GetRelease with BindMap HOT 3
- Migrate cql files from different directories
- [ASK]: Prepare Statement With Table Metadata HOT 1
- Help Regarding table `Update`
- Documentation - Get is by Primary Key, not Partition Key? HOT 2
- Query Level Timeout for Select Operation
- fix using timeout order in delete stmt HOT 6
- gocqlxtest: get test server configuration as from flags so from the environment variables
- What is the best way to update list<frozen<address>> in gocqlx?
- Null value cannot be unpacked into *[16]uint8
- Provide example for batches and updates HOT 1
- Canβt update UDT using gocqlx HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gocqlx.