如何在DynamoDB中以编程方式查询范围键 [英] How to query range key programmatically in DynamoDB

查看:80
本文介绍了如何在DynamoDB中以编程方式查询范围键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在DynamoDB中以编程方式查询范围键,我正在使用.Net AWSSDK,我可以使用以下代码在哈希键上进行查询:

How to query range key programmatically in DynamoDB, I am using .Net AWSSDK ,I am able to query on Hash key with below code :

GetItemRequest request = new GetItemRequest
            {
                TableName = tableName
            };
            request.Key = new Dictionary<string,AttributeValue>();

            request.Key.Add("ID",new AttributeValue { S = PKValue });
            GetItemResponse response = client.GetItem(request);

请建议,
预先感谢。

Please suggest, Thanks in advance.

推荐答案

DynamoDB中有两种主键:仅散列或散列范围。
在上面的代码中,我猜您的表仅适用于哈希,并且您使用哈希键检索具有等于PKValue的哈希键的元素。

There are two kinds of primary key in DynamoDB: Hash-only or Hash-Range. In the above code I guess your table is Hash-only and you use the hash key to retrieve an element with hashkey equals to PKValue.

如果您的表处于HR模式中,并且您想使用hashKey和rangeKey检索特定元素,则可以重复使用以上代码,此外,还可以在请求中添加{ RangeKey,new AttributeValue}。KEY

If your table is in H-R schema and you want to retrieve a specific element with a hashKey and rangeKey, you can reuse the above code and in addition, add the {"RangeKey", new AttributeValue } into your your request.KEY

另一方面,查询在DynamoDB中意味着不同的事情。查询将返回以一定顺序排序的行的列表。

On the other hand, query means a different thing in DynamoDB. Query will return you a list of rows sorted in some order.

这篇关于如何在DynamoDB中以编程方式查询范围键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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