NodeJS with DynamoDB throws error quot;AttributeValue may not contain an empty stringquot;(带有 DynamoDB 的 NodeJS 抛出错误“AttributeValue 可能不包含空字符串)
问题描述
我对 DynamoDB 不能接受空字符串作为属性值这一事实有疑问.如果有空字符串值,我总是必须在前端检查,否则 API 调用将由于 Dynamo DB 抛出的错误一个 AttributeValue 可能不包含空字符串"而失败.
I had a problem with the fact that DynamoDB cannot accept empty strings as value in attributes. I always had to check in the front end if there is an empty string value otherwise the API call would fail due to the error "An AttributeValue may not contain an empty string" that Dynamo DB would throw.
如果有一个递归函数可以删除根据 DynamoDB 无效的属性,以便 DynamoDB 中的 putItem 或更新请求起作用,我正在徘徊.
I was wandering if there is a recursive function that would remove the attributes that are not valid according to DynamoDB in order for the putItem or update request in DynamoDB to work.
推荐答案
关于 2017 年 1 月 3 日合并 #1283 更新了 AWS.DynamoDB.DocumentClient constructor-property 通过将标志 convertEmptyValues 放入客户端对象的选项字段来允许空值.
Latest update on Jan 3 2017 Merge #1283 updated the AWS.DynamoDB.DocumentClient constructor-property to allow for empty values by putting the flag convertEmptyValues into the options field of the client object.
例子:
const DynamoDB = new AWS.DynamoDB.DocumentClient( {
convertEmptyValues: true
} );
值得注意的问题
- DynamoDB.DocumentClient 应该支持空字符串属性#833李>
- 尊重 DynamoDB 文档客户端 #1281 中地图和列表的 convertEmptyValues 选项一个>
- 修复/doc客户端空嵌套成员#1283
- AWS 论坛线程 ID #90137
- 空属性会导致 DynamoDb boto/boto3 #1035 的 ValidationException
这篇关于带有 DynamoDB 的 NodeJS 抛出错误“AttributeValue 可能不包含空字符串"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:带有 DynamoDB 的 NodeJS 抛出错误“AttributeValue 可能不包含空字符串"
基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
