Skip to content

Instantly share code, notes, and snippets.

@kkroesch
Last active April 11, 2018 07:56
Show Gist options
  • Save kkroesch/ce265b1999e214c4ab2bacf208fd280c to your computer and use it in GitHub Desktop.
Save kkroesch/ce265b1999e214c4ab2bacf208fd280c to your computer and use it in GitHub Desktop.
Storing mail metadata in Cassandra DB.
CREATE KEYSPACE mail
WITH replication = {
'class': 'SimpleStrategy',
'replication_factor': 1
};
CREATE TABLE mailbox (
box_id text, year int,
received timestamp,
folder text,
sender text,
receipients list<text>,
subject text,
body text,
PRIMARY KEY ((box_id, year), received);
INSERT INTO mailbox (box_id, year, folder, received, sender, receipients, body)
VALUES ('torchwood', 2018, 'Inbox', dateof(now()), '[email protected]', ['[email protected]'], 'Sample text');
INSERT INTO mailbox (box_id, year, folder, received, sender, receipients, body)
VALUES ('torchwood', 2018, 'Inbox', dateof(now()), '[email protected]', ['[email protected]'], 'Sample text');
INSERT INTO mailbox (box_id, year, folder, received, sender, receipients, body)
VALUES ('torchwood', 2018, 'Inbox', dateof(now()), '[email protected]', ['[email protected]'], 'Sample text');
INSERT INTO mailbox (box_id, year, folder, received, sender, receipients, body)
VALUES ('torchwood', 2018, 'Inbox', dateof(now()), '[email protected]', ['[email protected]'], 'Sample text');
SELECT * from mailbox WHERE box_id = 'torchwood' and year = 2018 and folder='Inbox' ORDER BY folder DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment