Dynamo DB +输入项请求如何传递空值? [英] Dynamo DB + In put Item Request how to pass null value?
问题描述
我在模型中有一个字段已声明为字符串,如下所示:
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字段更新为null,而我想要的地址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 +输入项请求如何传递空值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!