具有DynamoDB的NodeJS抛出错误"AttributeValue可能不包含空字符串". [英] NodeJS with DynamoDB throws error "AttributeValue may not contain an empty string"

查看:111
本文介绍了具有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或update请求正常工作.

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 构造器属性通过将标记convertEmptyValues放入客户端对象的options字段来允许空值.

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 should support empty string properties #833
  • Respect convertEmptyValues option for Maps and Lists in the DynamoDB document client #1281
  • Fix/doc client empty nested members #1283
  • AWS Forum threadID #90137
  • Empty Attribute would cause ValidationException for DynamoDb boto/boto3 #1035

这篇关于具有DynamoDB的NodeJS抛出错误"AttributeValue可能不包含空字符串".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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