Reading and writing sets

Before getting into the more powerful operations we can perform on sets, let's start with the basics. Rerunning the scenario we explored earlier, let's naïvely use the exact same approach as we did the first time to record bob's status update. First, we'll read the value of the set:

SELECT "starred_by_users" FROM "user_status_updates" WHERE "username" = 'alice' AND "id" = 76e7a4d0-e796-11e3-90ce-5f98e903bf02;

Once again, we see that the value of the set is currently null:

This means that we can write a one-element set containing the text value bob to the starred_by_users column in the status update:

UPDATE "user_status_updates" ...

Get Learning Apache Cassandra - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.