获取最大日期/获取DynamoDB中最后添加的项目 [英] Get the Max Date / Get the last added item in DynamoDB

查看:190
本文介绍了获取最大日期/获取DynamoDB中最后添加的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好这是我的表格架构

联络人表格:

"KeySchema": [{
    "AttributeName": "DateTimeRetrieved",
    "KeyType": "HASH"
},{
    "AttributeName": "Id",
    "KeyType": "RANGE"
}]

我的主键有DateTimeRetrieved作为主键。我想检索输入到表中的最新datetime。它也等于最后添加的项datetime。

My primary key has DateTimeRetrieved as the primary key. I would like to retrieve the latest datetime that was entered into the table. It is also equal to the last added items datetime.

有没有办法查询这个?中。感谢!

Is there a way to query this? . Thanks!

推荐答案

不建议这样做:如果表格很小, $ c>选择所有数据并在应用程序级别中对其进行排序。

This is not recommended: If your table is small you can always Select all the data and order it in the application level.

尝试在散列键中查找顺序有点侮辱。对范围和二级指数进行排序。要有效地使用DynamoDB,应该将数据建模为桶(哈希键),并在第二层使用 Query 提出问题。

It is a bit abusive to try and find order in hash keys. Ordering is done on range and secondary indices. To use DynamoDB efficiently you should model the data as "buckets" (hash keys) and ask questions using Query on the 2nd level.

不知道你实际上是什么建模是很难帮助,但是一个好的阅读是 Local Secondary Indexes ,它允许您甚至对属性进行查询。
使用范围/ LSI,您可以给行的顺序,并查询最后一个。

Without knowing what you're actually modeling it is hard to help but a good read is the Local Secondary Indexes that allows you to have query even on an attribute. With range / LSI you can give order to rows and query the "last" one.

这篇关于获取最大日期/获取DynamoDB中最后添加的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆