0

if not found -> insert record into db

if found -> update all attributes in that record

sample data for insertion:

{
 "id": 366b7f5a-d246-4862-b280-c0485c130324",
 "activeDocumentGuid": "123bd81c-2804-4180-86d2-55b5a0ad379b",
 "activeDocumentName":"Sample_file_3"
 "ecid": "f7f6da108b784b61a315c4d6cf156d0e",
 "endDateTime": "2023-06-30T06:46:27.165Z",
 "expiryTime": 1688107657.508,
 "fileState": "active",
 "inActiveTime": 60,
 "occurred": "2023-06-30T06:45:59.876Z",
 "pluginVersion": "0.0.16",
 "requestId": "7447c667-9fed-4311-9bed-69b1e6403940",
 "seconds": 37.32,
 "startDateTime": "2023-06-30T06:45:59.876Z",
 "timezone": "Asia/Calcutta",
 "uuid": "366b7f5a-d246-4862-b280-c0485c130324",
 "uxpVersion": "uxp-6.3.0-local"
}

so I want to insert above data if id not found in DB else I need to update all attributes(values might be updated).

is it possible to do with single method in DynamoDB

Leeroy Hannigan
  • 11,409
  • 3
  • 14
  • 31
  • Does this answer your question? [How to prevent creating a new item in UpdateItem if the item does not exist](https://stackoverflow.com/questions/41873769/how-to-prevent-creating-a-new-item-in-updateitem-if-the-item-does-not-exist) – stdunbar Jun 30 '23 at 19:14

1 Answers1

1

It's possible, it's the default behaviour for UpdateItem API. It'll update existing values if the item exists, if it does not exist it'll create a new one.

Leeroy Hannigan
  • 11,409
  • 3
  • 14
  • 31