Created
November 8, 2024 08:50
-
-
Save tarasowski/ffa055724a978c0b394a6fb26e37acae to your computer and use it in GitHub Desktop.
dynamodb scan operation
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 characters
import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; | |
import { DynamoDBDocumentClient, ScanCommand } from "@aws-sdk/lib-dynamodb"; | |
const client = new DynamoDBClient({}); | |
const docClient = DynamoDBDocumentClient.from(client); | |
const TABLE_NAME = "Techstarter" | |
const scanOperation = async () => { | |
const command = new ScanCommand({ | |
TableName: TABLE_NAME, | |
}); | |
const response = await docClient.send(command); | |
return response.Items | |
}; | |
export const handler = async (event) => { | |
const items = await scanOperation() | |
// TODO implement | |
// we need to go to the database | |
// we need to scan (read) all entries from the database | |
// then we need to return all entries to the api gateway | |
// so api gateway will be able to send this data to the the client | |
const response = { | |
statusCode: 200, | |
body: JSON.stringify(items), | |
}; | |
return response; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment