Skip to content

Instantly share code, notes, and snippets.

@tarasowski
Created November 8, 2024 08:50
Show Gist options
  • Save tarasowski/ffa055724a978c0b394a6fb26e37acae to your computer and use it in GitHub Desktop.
Save tarasowski/ffa055724a978c0b394a6fb26e37acae to your computer and use it in GitHub Desktop.
dynamodb scan operation
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