dynamo-bao 0.3.5 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynamo-bao",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Simple powerful data modeling primitives for DynamoDB in JavaScript.",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -49,7 +49,6 @@
49
49
  "jest": "^29.7.0",
50
50
  "jsdoc": "^4.0.4",
51
51
  "prettier": "3.4.2",
52
- "serverless": "^3.38.0",
53
52
  "eslint-plugin-promise": "^6.1.1"
54
53
  },
55
54
  "bin": {
@@ -413,15 +413,17 @@ const MutationMethods = {
413
413
  );
414
414
  }
415
415
 
416
- // Add new constraint
417
- transactItems.push(
418
- await this._createUniqueConstraint(
419
- fieldName,
420
- dyNewValue,
421
- primaryId,
422
- constraint.constraintId,
423
- ),
424
- );
416
+ // Add new constraint unless value is null (clearing field removes constraint)
417
+ if (dyNewValue !== null) {
418
+ transactItems.push(
419
+ await this._createUniqueConstraint(
420
+ fieldName,
421
+ dyNewValue,
422
+ primaryId,
423
+ constraint.constraintId,
424
+ ),
425
+ );
426
+ }
425
427
  }
426
428
  }
427
429
 
@@ -528,12 +530,18 @@ const MutationMethods = {
528
530
  // Fetch the item since transactWrite doesn't return values
529
531
  const savedItem = await this.find(primaryId, { batchDelay: 0 });
530
532
 
533
+ // if the item doesn't exist, sleep for 200ms and try again
534
+ if (!savedItem.exists()) {
535
+ await new Promise((resolve) => setTimeout(resolve, 200));
536
+ savedItem = await this.find(primaryId, { batchDelay: 0 });
537
+ }
538
+
531
539
  logger.debug("savedItem", savedItem);
532
- logger.debug("savedItem.getPrimaryId()", savedItem.getPrimaryId());
533
540
 
534
541
  if (!savedItem.exists()) {
535
542
  throw new ConditionalError("Failed to fetch saved item", "update");
536
543
  }
544
+ logger.debug("savedItem.getPrimaryId()", savedItem.getPrimaryId());
537
545
 
538
546
  // Set the consumed capacity from the transaction
539
547
  savedItem._addConsumedCapacity(