1.0.3 • Published 5 months ago

node-red-contrib-dynamodb-variable v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

node-red-contrib-dynamodb-variable

A Node-RED node for interacting with AWS DynamoDB.

Developed by Andrii Lototskyi

šŸ“Œ Install

Run the following command in the root directory of your Node-RED installation:

npm install node-red-contrib-dynamodb-variable

This module allows performing CRUD operations and table management on DynamoDB using Node-RED.


šŸ“Œ Set AWS Credentials

Before using this module, configure AWS credentials inside the DynamoDB Config Node in Node-RED:

  • AWS Access Key ID
  • AWS Secret Access Key
  • AWS Region (e.g., us-east-1)

These credentials are required for authentication with AWS DynamoDB.


šŸ“Œ Available Operations

The DynamoDB Node supports the following operations:

1ļøāƒ£ Create a Table (createTable)
2ļøāƒ£ Get an item (getItem)
3ļøāƒ£ Put an item (putItem)
4ļøāƒ£ Update an item (updateItem)
5ļøāƒ£ Delete an item (deleteItem)
6ļøāƒ£ Scan a table (scan)
7ļøāƒ£ Query a table (query)

Each operation is selected in the DynamoDB Node via the dropdown menu.


šŸ“Œ Example Usage in Node-RED

1ļøāƒ£ Create a new DynamoDB Table

You can create a table with Primary Key, Sort Key (optional), and Global Secondary Index (GSI).

msg.payload = {
    "tableName": "Transactions",
    "keySchema": [
        { "AttributeName": "userId", "KeyType": "HASH" },
        { "AttributeName": "createdAt", "KeyType": "RANGE" }
    ],
    "attributeDefinitions": [
        { "AttributeName": "userId", "AttributeType": "S" },
        { "AttributeName": "createdAt", "AttributeType": "N" }
    ],
    "billingMode": "PAY_PER_REQUEST" // OR "PROVISIONED"
};
return msg;

2ļøāƒ£ Get an item from DynamoDB

msg.payload = {
    "tableName": "Users",
    "key": { "userId": "12345" }
};
return msg;

3ļøāƒ£ Put an item into DynamoDB

msg.payload = {
    "tableName": "Users",
    "data": {
        "userId": "12345",
        "name": "John Doe",
        "email": "john@example.com"
    }
};
return msg;

4ļøāƒ£ Update an item in DynamoDB

msg.payload = {
    "tableName": "Users",
    "key": { "userId": "12345" },
    "updateExpression": "SET email = :email",
    "expressionValues": { ":email": "newemail@example.com" }
};
return msg;

5ļøāƒ£ Delete an item from DynamoDB

msg.payload = {
    "tableName": "Users",
    "key": { "userId": "12345" }
};
return msg;

6ļøāƒ£ Scan a DynamoDB table

msg.payload = {
    "tableName": "Users",
    "filterExpression": "contains(name, :namePart)",
    "expressionValues": { ":namePart": "John" }
};
return msg;

7ļøāƒ£ Query a DynamoDB table (with Sort Key and GSI support)

msg.payload = {
    "tableName": "Transactions",
    "indexName": "TransactionIndex",
    "keyConditionExpression": "userId = :userId AND createdAt >= :startDate",
    "expressionValues": {
        ":userId": "user_123",
        ":startDate": 1700000000
    },
    "projectionExpression": "userId, amount, createdAt"
};
return msg;

ā˜ This will retrieve all transactions for user_123, filtering those created after timestamp 1700000000.


šŸ“Œ Features & Improvements

āœ… Supports all CRUD operations in DynamoDB
āœ… Table creation with HASH key, RANGE key, and GSI support
āœ… Billing Mode (PAY_PER_REQUEST or PROVISIONED) is configurable
āœ… AWS SDK v3 with @aws-sdk/lib-dynamodb for automatic data conversion
āœ… Projection and filter expressions for more optimized queries
āœ… Supports Global Secondary Index (GSI) and Sorting
āœ… Configured directly via Node-RED UI (no settings.js required)
āœ… Easy to configure and extend


šŸ“Œ Support & Issues

If you find any issues, please report them at:
GitHub Issues


šŸ“Œ Author & License

  • Author: Andrii Lototskyi
  • License: ISC
  • Repository: GitHub

šŸš€ Happy coding with Node-RED & AWS DynamoDB! šŸŽ‰

1.0.3

5 months ago

1.0.2

5 months ago