Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/minghsu0107/cassandra-golang-example
This repository shows basic Cassandra CRUD operations using Golang.
https://github.com/minghsu0107/cassandra-golang-example
cassandra cql golang
Last synced: 17 days ago
JSON representation
This repository shows basic Cassandra CRUD operations using Golang.
- Host: GitHub
- URL: https://github.com/minghsu0107/cassandra-golang-example
- Owner: minghsu0107
- Created: 2021-03-31T04:18:46.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-23T08:35:47.000Z (over 2 years ago)
- Last Synced: 2024-10-29T18:25:21.961Z (2 months ago)
- Topics: cassandra, cql, golang
- Language: Go
- Homepage:
- Size: 3.33 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```bash
docker-compose up
```