Registry /
database / stentor-user-storage-dynamo
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
UserStorage
✓ import { UserStorage } from 'stentor-user-storage-dynamo'
✗ import UserStorage from 'stentor-user-storage-dynamo'
Named export, not default.
UserStorageDynamoDB
✓ import { UserStorageDynamoDB } from 'stentor-user-storage-dynamo'
✗ const { UserStorageDynamoDB } = require('stentor-user-storage-dynamo')
CommonJS works but ESM is preferred for bundlers.
DynamoDBStorage
✓ import { DynamoDBStorage } from 'stentor-user-storage-dynamo'
Also exported as alias for UserStorageDynamoDB.
Initializes DynamoDB storage client with a DynamoDBClient, then demonstrates get and update operations on user storage.
import { UserStorageDynamoDB } from 'stentor-user-storage-dynamo';
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
const client = new DynamoDBClient({ region: 'us-east-1' });
const storage = new UserStorageDynamoDB(client, {
tableName: process.env.USER_STORAGE_TABLE ?? 'stentor-user-storage',
});
// Example: get user data by userId
const userId = 'user123';
storage.get(userId).then((data) => {
console.log('User data:', data);
}).catch((err) => {
console.error('Error fetching user data:', err);
});
// Example: update user data
const updateData = { lastSession: new Date().toISOString() };
storage.update(userId, updateData).then(() => {
console.log('User data updated');
});
Errors
Common errors & fixes
TypeError: Cannot destructure property 'TableName' of 'options' as it is undefined.
Missing or invalid table name configuration.
fixEnsure USER_STORAGE_TABLE is set or pass tableName in the constructor options.
Class constructor UserStorageDynamoDB cannot be invoked without 'new'
Using the constructor as a regular function without 'new' (common in CommonJS).
fixUse new UserStorageDynamoDB(client, options).
ValidationException: The provided key element does not match the schema
Table schema mismatch: storage expects partition key 'userId' but the DynamoDB table has a different key.
fixCreate DynamoDB table with partition key 'userId' (string).
Audit
Dependencies
@aws-sdk/lib-dynamodbrequiredDynamoDB client library (v3 SDK) - peer dependency
aws-sdkoptionalDynamoDB client library (v2 SDK) - peer dependency. Either v2 or v3 is required.
stentor-modelsrequiredCore Stentor model types and interfaces