Retrieving status updates for a specific time range
Having explored the limits of the WHERE
keyword in CQL, let's return to the user_status_updates
table. Suppose we'd like to build an "archive" feature for MyStatus that displays all of the user's status updates for a requested month. In CQL terms, we want to select a range of clustering columns; for instance, let's get back all of alice
's status updates created in May 2014:
SELECT "id", DATEOF("id"), "body" FROM "user_status_updates" WHERE "username" = 'alice' AND "id" >= MINTIMEUUID('2014-05-01') AND "id" <= MAXTIMEUUID('2014-05-31');
Before diving into the mechanics of this query, we can confirm that the only status update is the one with a UUID that was provided in the previous chapter, and was generated on May 29:
Creating time UUID ranges
In the preceding query, we encounter two new CQL functions...