Skip to main content

snippets_js

Integration

New integration from credential
const awsDynamodbClient = yepcode.integration.awsDynamodb("credential-slug");
New integration from plain authentication data
const { DynamoDBClient } = require("@aws-sdk/client-dynamodb");

const awsDynamodbClient = new DynamoDBClient({
credentials: {
accessKeyId: "accessKeyId",
secretAccessKey: "secretAccessKey",
},
});

List Tables

List tables
const { ListTablesCommand } = require("@aws-sdk/client-dynamodb");
const listTablesCommand = new ListTablesCommand({});

const listTablesResponse = await awsDynamodbClient.send(listTablesCommand);

console.log(listTablesResponse);

Get all Table Items

Get all table items
const { ScanCommand } = require("@aws-sdk/client-dynamodb");
const scanCommand = new ScanCommand({ TableName: "table-name" });

const scanResponse = await awsDynamodbClient.send(scanCommand);

console.log(scanResponse.Items);

Put Item

Put item
const { PutItemCommand } = require("@aws-sdk/client-dynamodb");
const putItemCommand = new PutItemCommand({
TableName: "table-name",
Item: {
"table-primary-key-name": { S: "table-primary-key-value" },
someOther: { S: "other-value" },
},
});

const putItemResponse = await awsDynamodbClient.send(putItemCommand);

console.log(putItemResponse);

Get Item

Get item
const { GetItemCommand } = require("@aws-sdk/client-dynamodb");
const getItemCommand = new GetItemCommand({
TableName: "table-name",
Key: {
"table-primary-key-name": { S: "table-primary-key-value" },
},
});

const getItemResponse = await awsDynamodbClient.send(getItemCommand);

console.log(getItemResponse);