Dynamo DB + In put Item Request 如何传递空值? [英] Dynamo DB + In put Item Request how to pass null value?

查看:17
本文介绍了Dynamo DB + In put Item Request 如何传递空值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have one field which i have declared as string in the model as show below:

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 然后出现以下错误:

Here in the Edit mode when i update Adderess 2 field as null then below error comes:

编辑属性失败:一个或多个参数值无效:AttributeValue 不能包含空字符串"

我知道会生成此错误,因为我将地址 2 字段更新为空,并且我想要 地址 2 字段不是强制性的(可以传递数据或也可以将该列留空")

I know this Error is generated because i am updating address 2 field as null and that what i want Address 2 field is not mandatory(One can pass data or can also left that column as blank")

推荐答案

最后我做对了,方法可能有些不同,但对我有用!!!

Finally i got this right, The way might be some what different but it work for me !!!

这是相同的代码.

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

然后我在条件上添加值.

And then i am adding the value on the condition.

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

衷心感谢所有帮助过我的人,干杯!!!

Thank you to all from bottom of my heart :)who tried to help me, Cheers !!!

这篇关于Dynamo DB + In put Item Request 如何传递空值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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