@squiz/db-lib 1.70.0 → 1.71.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/db-lib",
3
- "version": "1.70.0",
3
+ "version": "1.71.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "private": false,
@@ -774,7 +774,6 @@ describe('AbstractRepository', () => {
774
774
  TransactItems: [
775
775
  {
776
776
  Delete: {
777
- ConditionExpression: 'attribute_exists(pk)',
778
777
  Key: {
779
778
  pk: 'test_item#foo',
780
779
  sk: '#meta',
@@ -307,6 +307,8 @@ export abstract class AbstractDynamoDbRepository<SHAPE extends object, DATA_CLAS
307
307
  };
308
308
 
309
309
  if (transaction.id?.length) {
310
+ // For transaction block, don't worry if the item being deleted does not exist
311
+ delete deleteCommandInput.ConditionExpression;
310
312
  // this command will be executed together with
311
313
  // other db write commands in the "transaction block"
312
314
  this.dbManager.addWriteTransactionItem(transaction.id, {
@@ -49,6 +49,9 @@ export class DynamoDbManager<TRepositories> {
49
49
  if (this.transactionItems[transactionId] === undefined) {
50
50
  throw new TransactionError(`No items in transaction '${transactionId}' to execute`);
51
51
  }
52
+ if (!this.transactionItems[transactionId].length) {
53
+ return;
54
+ }
52
55
 
53
56
  return tracer.startActiveSpan(
54
57
  'executeTransaction',