retrieve auto-generated partition key
Closed this issue · 1 comments
vishnurpiper commented
Just started using this library in one of my projects and have a quick(hopefully!) question - I have the partition key for my entity autogenerated using the default property, something like below -
id : { type: 'string', partitionKey: true, default: uuidv4() }
After a PUT, Is there a way for me to know the id generated?
naorpeled commented
Hey @vishnurpiper,
unfortunately there's no way to retrieve an item with a generated hash key you just PUT, it's a DynamoDB constraint (See here).
As a workaround, you have two options:
- Use update with
returnValues: 'ALL_NEW'
. - Generate the UUID before the operation instead of using the default property on the id attribute.
Let me know if you have any other questions.