DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.
Is your feature request related to a problem? Please describe.
Often when doing updates, you need to prevent against upserts with something like update.onlyIfAttribute('pk').attributeExists(). It often is not really a failure when the condition fails; it just means "there was no item there to update". You then have to catch the error that DynamoDB throws and ignore the ConditionalCheckFailedException.
Describe the solution you'd like
I'd like to be able to do this:
await store.update(file.pk, file.sk)
.updateAttribute('filename').set(newValue)
.onlyIfAttribute('pk').attributeExists() // but don't allow upserts
.ignoreConditionalCheckFailed() // if there's no item there, that's fine
.exec();
Describe alternatives you've considered
I currently have a reusable catch function that I use:
export default function ignoreConditionalCheckFailedException(err: any): void {
if (err && err.code !== 'ConditionalCheckFailedException') {
throw err;
}
}
await update.exec().catch(ignoreConditionalCheckFailedException);
Is your feature request related to a problem? Please describe. Often when doing updates, you need to prevent against upserts with something like
update.onlyIfAttribute('pk').attributeExists()
. It often is not really a failure when the condition fails; it just means "there was no item there to update". You then have to catch the error that DynamoDB throws and ignore the ConditionalCheckFailedException.Describe the solution you'd like I'd like to be able to do this:
Describe alternatives you've considered I currently have a reusable catch function that I use: