Support of DynamoDB for Node.js - JavaScript
CAST supports DynamoDB via its com.castsoftware.nodejs extension. Details about how this support is provided for Node.js JavaScript source
code is discussed below.
Objects
Icon | Description |
---|---|
![]() |
Node.js DynamoDB Endpoint |
![]() |
Node.jsDynamoDB Table |
Links
DynamoDB API
Link Type | Function api v2 | Commands from SDK V3 imported from ‘@aws-sdk/client-dynamodb’ |
---|---|---|
No Link | createGlobalTable createTable |
- |
useSelectLink | createBackup getItem batchGetItem transactWriteItems batchWriteItem restoreTableToPointInTime |
CreateTableCommand BatchGetItemCommand GetItemCommand |
useDeleteLink | deleteTable deleteItem transactWriteItems batchWriteItem |
DeleteTableCommand DeleteItemCommand |
useUpdateLink | transactWriteItems batchWriteItem updateItem updateTable putItem restoreTableToPointInTime restoreTableFromBackup |
PutItemCommand UpdateItemCommand UpdateCommand |
DocumentClient
Link Type | Function api v2 | Commands from SDK V3 imported from ‘@aws-sdk/client-dynamodb’ |
---|---|---|
useSelectLink | batchGet transactGet get scan query batchWrite transactWrite |
- |
useDeleteLink | batchWrite transactWrite delete |
- |
useUpdateLink | put update batchWrite transactWrite |
- |
Code samples
API v2 sample
These declaration will establish a connection to the database located on localhost:
var AWS = require("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 database “myDatabase”:
/* 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
});