From b093215f7543ee1b6614c391a4992ff80442e8a2 Mon Sep 17 00:00:00 2001 From: Jeferson Alves Date: Sun, 10 Mar 2024 16:42:32 +0000 Subject: [PATCH 1/2] fix(dynamodb-dao): :bug: Refactor DynamoDB get method to handle missing Item property --- src/dao/dynamo/dao.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dao/dynamo/dao.ts b/src/dao/dynamo/dao.ts index c7b5072..db69ce7 100644 --- a/src/dao/dynamo/dao.ts +++ b/src/dao/dynamo/dao.ts @@ -38,7 +38,7 @@ const get = async ({ }: { params: GetCommandInput, fields?: string[] }): Promise => { const command = new GetCommand({ ...params, ...mountProjectionExpression({ fields }) }) - const { Item } = await documentInstance.send(command) as { Item: T } + const { Item } = await documentInstance.send(command) as Omit & { Item: T } ?? {} return Item } From 940b6168c3d73a6debd1808811229273b689b7fd Mon Sep 17 00:00:00 2001 From: Jeferson Alves Date: Sun, 10 Mar 2024 16:42:45 +0000 Subject: [PATCH 2/2] fix(dynamodb-dao): :sparkles: Update package versions and fix formatting in dao.ts --- package-lock.json | 4 ++-- package.json | 2 +- src/dao/dynamo/dao.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 39bd2eb..b0f0551 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "adapcon-utils-js", - "version": "1.2.0", + "version": "1.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "adapcon-utils-js", - "version": "1.2.0", + "version": "1.2.1", "dependencies": { "@aws-sdk/client-dynamodb": "^3.496.0", "@aws-sdk/client-lambda": "^3.496.0", diff --git a/package.json b/package.json index 15943e3..af1a770 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "adapcon-utils-js", - "version": "1.2.0", + "version": "1.2.1", "description": "Utils library for Javascript", "keywords": [], "author": { diff --git a/src/dao/dynamo/dao.ts b/src/dao/dynamo/dao.ts index db69ce7..db66ee7 100644 --- a/src/dao/dynamo/dao.ts +++ b/src/dao/dynamo/dao.ts @@ -32,10 +32,10 @@ const documentInstance = DynamoDBDocument.from(dynamoInstance, { marshallOptions: { removeUndefinedValues: true } }) -const get = async ({ +const get = async({ params, fields = [] -}: { params: GetCommandInput, fields?: string[] }): Promise => { +}: { params: GetCommandInput, fields?: string[] }): Promise => { const command = new GetCommand({ ...params, ...mountProjectionExpression({ fields }) }) const { Item } = await documentInstance.send(command) as Omit & { Item: T } ?? {}