@twin.org/entity-storage-connector-dynamodb 0.0.1-next.10 → 0.0.1-next.11

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.
@@ -295,7 +295,11 @@ class DynamoDbEntityStorageConnector {
295
295
  [DynamoDbEntityStorageConnector._PARTITION_ID_NAME]: DynamoDbEntityStorageConnector._PARTITION_ID_VALUE,
296
296
  ...entity
297
297
  },
298
- ConditionExpression: conditionExpression,
298
+ // Only set the condition expression if we have conditions to match
299
+ // and the primary key exists, otherwise we are creating a new object
300
+ ConditionExpression: core.Is.stringValue(conditionExpression)
301
+ ? `(attribute_exists(${this._primaryKey.property}) AND ${conditionExpression}) OR attribute_not_exists(${this._primaryKey.property})`
302
+ : undefined,
299
303
  ExpressionAttributeNames: attributeNames,
300
304
  ExpressionAttributeValues: attributeValues
301
305
  });
@@ -293,7 +293,11 @@ class DynamoDbEntityStorageConnector {
293
293
  [DynamoDbEntityStorageConnector._PARTITION_ID_NAME]: DynamoDbEntityStorageConnector._PARTITION_ID_VALUE,
294
294
  ...entity
295
295
  },
296
- ConditionExpression: conditionExpression,
296
+ // Only set the condition expression if we have conditions to match
297
+ // and the primary key exists, otherwise we are creating a new object
298
+ ConditionExpression: Is.stringValue(conditionExpression)
299
+ ? `(attribute_exists(${this._primaryKey.property}) AND ${conditionExpression}) OR attribute_not_exists(${this._primaryKey.property})`
300
+ : undefined,
297
301
  ExpressionAttributeNames: attributeNames,
298
302
  ExpressionAttributeValues: attributeValues
299
303
  });
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/entity-storage-connector-dynamodb - Changelog
2
2
 
3
- ## v0.0.1-next.10
3
+ ## v0.0.1-next.11
4
4
 
5
5
  - Initial Release
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity-storage-connector-dynamodb",
3
- "version": "0.0.1-next.10",
3
+ "version": "0.0.1-next.11",
4
4
  "description": "Entity Storage connector implementation using DynamoDb storage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "@aws-sdk/util-dynamodb": "3.656",
20
20
  "@twin.org/core": "next",
21
21
  "@twin.org/entity": "next",
22
- "@twin.org/entity-storage-models": "0.0.1-next.10",
22
+ "@twin.org/entity-storage-models": "0.0.1-next.11",
23
23
  "@twin.org/logging-models": "next",
24
24
  "@twin.org/nameof": "next"
25
25
  },