简体   繁体   English

在 DynamoDB 中获取最近 15 分钟的所有项目

[英]Get all items of the last 15 minutes in DynamoDB

As I come from RDBM background I am bit confuse with DynamoDB, how to write this query.由于我来自 RDBM 背景,我对 DynamoDB 有点困惑,不知道如何编写这个查询。

Problem : need to filter out those data which is more than 15 minutes.问题:需要过滤掉那些超过15分钟的数据。

I have created GSI with hashkey materialType and createTime (create time format Instant.now().toEpochMilli() ).我已经使用 hashkey materialTypecreateTime创建了 GSI(创建时间格式Instant.now().toEpochMilli() )。

Now I have to write a java query which gives those values which is more than 15 minutes.现在我必须编写一个 java 查询,它给出超过 15 分钟的那些值。

Here is an example using cli.这是一个使用 cli 的例子。

:v1 should be the material type I'd that you are searching on. :v1应该是我要搜索的材料类型。 :v2 should be your epoch time in milliseconds for 30 mins ago which you will have to calculate. :v2应该是你必须计算的 30 分钟前的纪元时间(以毫秒为单位)。

aws dynamodb query \
    --table-name mytable \
    --index-name myindex
    --key-condition-expression "materialType = :v1 AND create time > :v2" \
    --expression-attribute-values '{
    ":v1": {"S": "some id"},
    ":V2": {"N": "766677876567"}
}'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM