-
Notifications
You must be signed in to change notification settings - Fork 21
feat: support update as create in bundle service #80
feat: support update as create in bundle service #80
Conversation
…hen trying to lock resources for 'updates'
// allow for update as create scenario | ||
if (itemResponse instanceof ResourceNotFoundError && itemsToLock[i].operation !== 'update') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this works, but it will inadvertently enable update as crate for all customers using bundles/transactions.
DynamoDbDataService
has a parameter supportUpdateCreate
that enables update as create for the regular update operation but doesn't address bundles/transactions. I think that we can pass down that same parameter to DynamoDbBundleService
and use it to conditionally apply your changes.
constructor(dynamoDb: DynamoDB, supportUpdateCreate: boolean = false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added the supportUpdateCreate
flag to dynamoDbBundleService.ts. Creating a test seems not so trivial. I'll give it a shot.
…to true in constructor.
…hir-works-on-aws-persistence-ddb into allow_update_as_create
… update as create.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! @carvantes for final review and merge
Description of changes:
In order to lock resources for operations other than 'create' the latest version ID needs to be looked up first.
If the resource isn't found a ResourceNotFoundError is thrown.
With this change only ResourceNotFoundErrors for operations other than 'update' are being counted and result in a failed transaction.
By allowing 'update' operation for resources that don't exist in dynamo yet using update as create is possible.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.