Last active
July 19, 2021 13:14
-
-
Save Ranjanivraman/d43f42dfcce37f98d29d6f624cbe319e to your computer and use it in GitHub Desktop.
Revisions
-
Ranjanivraman revised this gist
Jul 19, 2021 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,20 +5,20 @@ export async function getReturnItem(orderId: string, sku: string): Promise<Retur const db: DocumentClient = new DocumentClient({ region: process.env.AWS_REGION as string, }); const myKey: DocumentClient.Key = { orderId, sku, }; const params: DocumentClient.GetItemInput = { TableName: process.env.tablename as string, Key: myKey, }; const response: DocumentClient.ItemResponse = await db.get(params).promise(); if (response.Item) { return <ReturnItem>response.Item; } throw new Error(`Couldn't find order ${orderId} and sku ${sku} in MyTablename table`); } -
Ranjanivraman created this gist
Jul 19, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import { DocumentClient } from "aws-sdk/clients/dynamodb"; import { ReturnItem } from "../Type/ReturnItem"; export async function getReturnItem(orderId: string, sku: string): Promise<ReturnItem> { const db: DocumentClient = new DocumentClient({ region: process.env.AWS_REGION as string, }); const rdtEtlKey: DocumentClient.Key = { orderId, sku, }; const params: DocumentClient.GetItemInput = { TableName: process.env.tablename as string, Key: rdtEtlKey, }; const response: DocumentClient.ItemResponse = await db.get(params).promise(); if (response.Item) { return <ReturnItem>response.Item; } throw new Error(`Couldn't find order ${orderId} and sku ${sku} in RDTETL table`); }