2

I have created the following table, but now want to insert the data in things list which i could not because CQL want me to specify the Event time. I dont have that but yes I have OrderId .

What's best way to handle this situation ?

CREATE TABLE "Orders_By_Time" (OrderId text, EventTime timestamp, ThingsList list, PRIMARY KEY (OrderId, EventTime) ) WITH CLUSTERING ORDER BY (EventTime DESC);

Thanks,

BrianC
  • 10,591
  • 2
  • 30
  • 50
Usman
  • 125
  • 3
  • 10

1 Answers1

3

When you insert data you need to specify all parts of the primary key, so you can use dateof(now()) to generate a timestamp for the current time.

See this similar question:

How to get current timestamp with CQL while using Command Line?

Community
  • 1
  • 1
Jim Meyer
  • 9,275
  • 1
  • 24
  • 49
  • Hey Jim, Yes sure I can enter the record with dateof(now). But what I want is to update the record like, add entries in ThingsList across that OrderId. For example I have already entered a record. But now I want to enter the thingslist for that orderId later. I only know the order Id for that time series entry but not the timestamp of that entry. Please suggest what is better solution may be i need to change the data model to achieve this – Usman Jan 10 '15 at 14:06
  • 1
    Then you probably wouldn't want EventTime as part of your primary key, it would just be a regular column. The way you've defined your table is as a time series, but with a time series you are usually recording events over time and not updating those events later. If you need both a time series and a way to update it later, you could have two tables, orders_by_time and orders_by_orderid, with the ThingsList being in the orders_by_orderid table with just orderid as the primary key. – Jim Meyer Jan 10 '15 at 14:27