Handling Empty Strings
AWS DynamoDB does not currently support empty strings, trying to insert / update attributes with an empty string value will fail
One or more parameter values were invalid: An AttributeValue may not contain an empty string
By default ( for compatibility with previous versions reasons ), @awspilot/dynamodb will leave empty strings untouched
( you will need to implement your own logic to replace empty strings )
As of @1.2.4 you can have empty strings replaced with your custom defined value:
const DynamodbFactory = require('@awspilot/dynamodb')
DynamodbFactory.config( {empty_string_replace_as: YOUR_VALUE } );
var DynamoDB = new DynamodbFactory(credentials)
Notes:
Setting 'empty_string_replace_as' to null will return as null, not empty string
Eg: { attribute: '' }, converted to { attribute: null }, returned as { attribute: null }
Setting 'empty_string_replace_as' to undefined will loose the attribute
Eg: { attribute: '' } converted to {}, returned as {}
Setting 'empty_string_replace_as' to 'STRING' will insert/update as 'STRING' and convert back to empty string at get/query/scan.
Eg. { empty_string_replace_as: "\0" }
{ attribute: '' }, converted to { attribute: "\0" }, returned as { attribute: '' }