Support of DynamoDB for Node.js - TypeScript

CAST supports DynamoDB via its com.castsoftware.typescript extension. Details about how this support is provided is discussed below.

Supported APIs

Only the SDK V2 is currently supported.

Objects

Icon Description

Node.js DynamoDB Endpoint

Node.js DynamoDB Table

API: DynamoDB (SDK V2 or SDK V3)

//SDKV2
import AWS from "aws-sdk";
const dynamodb = new AWS.DynamoDB();

or

//SDKV3
import * as AWS from "@aws-sdk/client-dynamodb";
const dynamodb = new AWS.DynamoDB();
Link Type Function
No Link

createGlobalTable

createTable

useSelectLink

createBackup

getItem

batchGetItem

transactWriteItems

batchWriteItem

restoreTableToPointInTime

useDeleteLink

deleteTable

deleteItem

transactWriteItems

batchWriteItem

useUpdateLink

transactWriteItems

batchWriteItem

updateItem

createBackup

updateTable

putItem

restoreTableToPointInTime

restoreTableFromBackup

API: Commands from SDK V3

imported from '@aws-sdk/client-dynamodb'
Link Type Function
No Link

CreateGlobalTableCommand

CreateTableCommand

useSelectLink

CreateBackupCommand

GetItemCommand

BatchGetItemCommand

TransactGetItemsCommand

BatchGetItemCommand

BatchWriteItemCommand

TransactWriteItemsCommand

RestoreTableToPointInTimeCommand

useDeleteLink

DeleteItemCommand

DeleteTableCommand

TransactWriteItemsCommand

BatchWriteItemCommand

useUpdateLink

TransactWriteItemsCommand

BatchWriteItemCommand

UpdateItemCommand

CreateBackupCommand

UpdateTableCommand

PutItemCommand

RestoreTableFromBackupCommand

API: DocumentClient

Link Type Function
useSelectLink

batchGet

transactGet

get

scan

query

batchWrite

transactWrite

useDeleteLink

batchWrite

transactWrite

delete

useUpdateLink

put

update

batchWrite

transactWrite

What results can you expect?

Code samples

These declarations will establish a connection to the database located on localhost:

import AWS from "aws-sdk";

AWS.config.update({
  region: "us-west-2",
  endpoint: "http://localhost:8000"
});

var dynamodb = new AWS.DynamoDB();

These declarations will create a useUpdateLink from code to the table “Music”.

/* This example adds a new item to the Music table. */

var params = {
  Item: {
    "AlbumTitle": {
      S: "Somewhat Famous"
    }, 
    "Artist": {
      S: "No One You Know"
    }, 
    "SongTitle": {
      S: "Call Me Today"
    }
  }, 
  ReturnConsumedCapacity: "TOTAL", 
  TableName: "Music"
};
dynamodb.putItem(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});