从日期boto订购的DynamoDB中返回所有项目
我试图从DynamoDB表中返回所有项目,并按日期排序。表结构是:
ID | DATE | 类别 | 电子邮件 | 错误 | ISREAD | 消息 |
---|
,ID作为主密钥,将日期定义为“排序密钥”。
据我了解,无法订购扫描()操作,因此我试图使用打开查询。
我已经能够构建一个可以轻松返回特定ID的查询,但是我找不到仅允许查询返回所有内容的示例,可能会使用通配符?
response = table.query(KeyConditionExpression=Key('_id').eq('e2c0cad8-7630-48c6-8fc3-6b579d5ca021'))
是否有一种方法可以简单地基于可以返回有序列表而无需特定过滤器的键的密钥查询?
I am attempting to return all items from a dynamodb table with results ordered by date. The tables structure is:
ID | Date | Category | Errors | IsRead | Message |
---|
With ID as the primary key and date defined as the sort key.
As I understand it, a scan() operation cannot be ordered so I am attempting to utilise an open query instead.
I have been able to construct a query that can easily return a particular ID but I am unable to find examples that simply allow a query to return all, possibly using a wildcard?
response = table.query(KeyConditionExpression=Key('_id').eq('e2c0cad8-7630-48c6-8fc3-6b579d5ca021'))
Is there an approach that will simply allow a query based on a key that can return an ordered list without requiring a specific filter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于日期定义为排序键,因此使用GraphQl调用应该可以使用。而不是查询或扫描,请尝试使用执行。我的python有点生锈,但基本上是这样的:
据我所记得的,这些调用在RCU/WCU消耗中也有些轻一些。不过,请仔细检查响应中的returnConsumedCapacity。
dyanamodb UI还具有内置的partiql编辑器来帮助构建这些查询。
Since date is defined as the sort key, this should be possible using a GraphQL call. Instead of Query or Scan, try using ExecuteStatement. My Python is a little rusty, but basically something like this:
From what I remember, these calls are a little lighter on the RCU/WCU consumption as well. Double check that with the ReturnConsumedCapacity on the response though.
The DyanamoDB UI also has the built-in PartiQL editor to help with building these queries.