0

I want to query a Dynamo DB table based on an attribute UpdateTime such that I get the records which are updated in the last 24 hours. But this attribute is not an index in the table. I understand that I need to make this column as an index. But I do not know how do I write a query expression for this.

I saw this question but the problem is I do not know the table name on which I want to query before runtime.

Community
  • 1
  • 1
rightCoder
  • 281
  • 1
  • 3
  • 18

1 Answers1

1

To find out the table names in your DynamoDB instance, you can use the "ListTables" API: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListTables.html.

Another way to view tables and their data is via the DynamoDB Console: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ConsoleDynamoDB.html.

Once you know the table name, you can either create an index with the UpdateTime attribute as a key or scan the whole table to get the results you want. Keep in mind that scanning a table is a costly operation.

Alternatively you can create a DynamoDB Stream that captures all of the changes to your tables: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html.

Reid Hughes
  • 731
  • 7
  • 5
  • I made `UpdateTime` as an index and have decided to use `QuerySpec` to query the table, something like: `QuerySpec spec = new QuerySpec().withHashKey........` I do not know how to write the query spec for this case where I need all records updated in last 24 hours. Can you help me in this? – rightCoder Apr 21 '16 at 08:56