DynamoDb 范围键可以为空吗? [英] Can DynamoDb range key be empty?

查看:30
本文介绍了DynamoDb 范围键可以为空吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将 DynamoDb 用于我的一个应用程序.

I am looking at using DynamoDb for one of my applications.

我想知道是否可以将属性设置为范围键,然后为某些记录(空或 null)不填充它.

I wanted to know if it's possible to set an attribute as range key and then leave it unpopulated for certain records(either empty or null).

推荐答案

不能插入带有 Range Key 为空值或没有 Range 键的项目.

You can't insert an item with Range Key as empty value or without the Range key.

如果不包括 Range 键.你会得到以下错误:-

If the Range key is not included. You would get the below error:-

"One of the required keys was not given a value"

如果 Range 键填充了 ''(即空字符串)

If the Range key is populated with '' (i.e. empty string)

"message": "One or more parameter values were invalid: An AttributeValue may not contain an empty string"

来自 AWS 文档:-

From AWS Doc:-

添加项目时,主键属性是唯一的必需的属性.属性值不能为空.字符串和二进制类型属性的长度必须大于零.设置类型属性不能为空.具有空值的请求将是被 ValidationException 异常拒绝.

When you add an item, the primary key attribute(s) are the only required attributes. Attribute values cannot be null. String and Binary type attributes must have lengths greater than zero. Set type attributes cannot be empty. Requests with empty values will be rejected with a ValidationException exception.

这篇关于DynamoDb 范围键可以为空吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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