user3130782
user3130782

Reputation: 861

SELECT range from Map in Cassandra

I have table in Cassandra and I wish to select 10 last blob from usermgmt.user_history.history

CREATE TABLE usermgmt.user_history (
  id        uuid, 
  history   Map<timeuuid, blob>,
  PRIMARY   KEY(id)
);

I feel like it was easy with 5 year old Cassandra design with ordered typed column names. But now I can't find method to select range of 10 last entries in recent Cassandra 3.0

Upvotes: 2

Views: 133

Answers (1)

Christophe Schmitz
Christophe Schmitz

Reputation: 2996

How about this:

CREATE TABLE usermgmt.user_history (
  id        uuid, 
  history_time timestamp,
  history_blob blob,
  PRIMARY   KEY(id, history_time)
);

Then,

SELECT * FROM usermgmt.user_history WHERE id = your-uuid ORDER BY history_time limit 10;

Upvotes: 5

Related Questions