gpt4 book ai didi

amazon-dynamodb - DynamoDB 是否支持在表的主键中使用其中一种数据类型?

转载 作者:行者123 更新时间:2023-12-04 18:13:09 34 4
gpt4 key购买 nike

我是 CouchDB 的忠实粉丝,并且完全爱上了每个文档发出不止一次的 map 函数。我想知道在 DynamoDB 中是否可以通过使用字符串或数字集类型作为散列和范围主键的一部分(作为散列或范围属性)来实现稍微相似的东西,以便可以在多种方式。

谢谢!

最佳答案

有趣的问题 - 恐怕代码检查和/或测试会按顺序进行,但我对此表示怀疑:

Amazon DynamoDB Data Types支持字符串和数字集以及 CreateTable 的 API当然也允许为 AttributeType 提交集合类型(毕竟它只是一个字符串参数),没有任何地方的概念,他们的示例都没有这样做,并且 AWS 管理控制台中的 CreateTable UI 明确地将类型限制为哈希和范围键属性的字符串或数字也是如此(参见 Amazon DynamoDB - Internet-Scale Data Storage the NoSQL Way 中的第一张图片)。

我想有人在公告网络广播中提到他们从列出的 Primary Key 开始。概念,但可能会考虑在 future 扩展它(虽然我没有 100% 正确地记忆这一点)。

更新:检查/测试结果

不支持设置数据类型作为主键 目前确实,请参阅 class KeySchemaElement 的 API 文档:

/**
* Sets the value of the AttributeType property for this object.
* <p>
* <b>Constraints:</b><br/>
* <b>Allowed Values: </b>S, N
*
* @param attributeType The new value for the AttributeType property for this object.
*
* @see ScalarAttributeType
*/
public void setAttributeType(String attributeType) {
this.attributeType = attributeType;
}

修改 Table Example相应地产生预期的异常:

INFO: Received error response: Status Code: 400, AWS Service: AmazonDynamoDB, AWS Request ID: XXXXXXXX, AWS Error Code: ValidationException, AWS Error Message: 1 validation error detected: Value 'SS' at 'keySchema.hashKeyElement.attributeType' failed to satisfy constraint: Member must satisfy enum value set: [N, S] Failed to create table TestTable

关于amazon-dynamodb - DynamoDB 是否支持在表的主键中使用其中一种数据类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8926017/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com