Dynamo DB +输入项请求如何传递空值?

Trilok帕塔克

我在模型中有一个字段已声明为字符串,如下所示:

App.Student= DS.Model.extend({
name: DS.attr('string'),
address1: DS.attr('string'),
address2: DS.attr('string'),
city: DS.attr('string'),
state: DS.attr('string'),
postal: DS.attr('string'),
country: DS.attr('string'),
});

当我将Adderess 2字段更新为null时,在编辑模式下出现以下错误:

"Failed to edit property: One or more parameter values were invalid: An AttributeValue may not contain an empty string"

我知道会产生此错误,因为我将地址2字段更新为null,而我想要的地址2字段不是必需的(一个可以传递数据,也可以将该列留为空白”)

Trilok帕塔克

终于我明白了,方法可能有所不同,但对我有用!

这是相同的代码。

AttributeUpdates: {
                     Address2: 
                     {
                        Action: "DELETE"
                     },
                  }

然后我在条件上添加值。

if (propertyObj.address2) {
        params.AttributeUpdates.address2 = {
            Value: {
                S: propertyObj.address2
            },
            Action: "PUT"
        }
    }

衷心感谢大家:)谁想帮助我,干杯!

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章