Skip to content

Commit

Permalink
Some inline code comments for beginners
Browse files Browse the repository at this point in the history
The program panics when the keyspace or table was not available. The querying
part failed when an index was not prebuilt.

These information may be common knowledge for Cassandra experts. But I was a
beginner who was considering cassandra and gocql over sqlite and had to spend
time finding these pre-requisite cql instructions myself. Since it is the basic
example, Documenting these CQL queries will help beginners.
  • Loading branch information
psankar committed Aug 20, 2014
1 parent f35c807 commit dc2da1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ Ben Frye <[email protected]>
Fred McCann <[email protected]>
Dan Simmons <[email protected]>
Muir Manders <[email protected]>
Sankar P <[email protected]>
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ Example
-------

```go
/* Before you execute the program, Launch `cqlsh` and execute:
create keyspace example with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
create table example.tweet(timeline text, id UUID, text text, PRIMARY KEY(id));
create index on example.tweet(timeline);
*/
package main

import (
Expand All @@ -112,7 +117,9 @@ func main() {
var id gocql.UUID
var text string

// select a single tweet
/* Search for a specific set of records whose 'timeline' column matches
* the value 'me'. The secondary index that we created earlier will be
* used for optimizing the search */
if err := session.Query(`SELECT id, text FROM tweet WHERE timeline = ? LIMIT 1`,
"me").Consistency(gocql.One).Scan(&id, &text); err != nil {
log.Fatal(err)
Expand Down

0 comments on commit dc2da1c

Please sign in to comment.