Last active
April 11, 2018 07:56
-
-
Save kkroesch/ce265b1999e214c4ab2bacf208fd280c to your computer and use it in GitHub Desktop.
Storing mail metadata in Cassandra DB.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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