Skip to content

This repository shows basic Cassandra CRUD operations using Golang.

Notifications You must be signed in to change notification settings

minghsu0107/cassandra-golang-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cassandra Golang Example

This repository shows basic Cassandra CRUD operations using Golang.

Overview

We will create a keyspace according to the scripts/cassandra.cql:

CREATE KEYSPACE roster WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1};
USE roster;
CREATE TABLE employees (
    id UUID,
    firstname varchar,
    lastname varchar,
    age int,
    PRIMARY KEY(id)
);
CREATE INDEX ON employees(age);

CREATE TABLE messages (
    channel UUID,
    msg_id int,
    username varchar,
    content text,
    PRIMARY KEY((channel), msg_id, username)
) WITH CLUSTERING ORDER BY (msg_id DESC);

The keyspace will be created in Cassandra on startup. Note that we have created an index on age field so that we could query by age besides primary key.

Usage

docker-compose up

About

This repository shows basic Cassandra CRUD operations using Golang.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages