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'),
});
Here in the Edit mode when i update Adderess 2 field as null then below error comes:
"Failed to edit property: One or more parameter values were invalid: An AttributeValue may not contain an empty string"
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")
Dynamodb can't accept a key with an explicitly NULL value.
Can the DynamoDB sort key be null? DynamoDB does not support null for sort key.
Empty value support gives you greater flexibility to use attributes for a broader set of use cases without having to transform such attributes before sending them to DynamoDB. List, Map, and Set data types also support empty String and Binary values.
By default, the DynamoDB write operations ( PutItem , UpdateItem , DeleteItem ) are unconditional: Each operation overwrites an existing item that has the specified primary key.
AWS finally resolved this issue. DynamoDb now supports empty string values for non-key attributes: https://aws.amazon.com/about-aws/whats-new/2020/05/amazon-dynamodb-now-supports-empty-values-for-non-key-string-and-binary-attributes-in-dynamodb-tables/
If you are using DynamoDB (not DocumentClient) you can specify nulls like this
const putItem: PutItemInput = {
TableName: `${process.env.PRIMARY_TABLE}`,
Item: {
key: { S: ${userId}` },
someField: { NULL: true }
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With