dynamo-update-expr
v1.0.2
Published
A simple Dynamo update Expression generator.
Downloads
5
Maintainers
Readme
dynamo-update-expr
Simple DynamoDB update expression generator.
As of now there is only support for DynamoDB SET expression. I will try to maintain this repository and add support for ADD, REMOVE, DELETE expressions as well
Installation
npm i dynamo-update-expr
Usage
const { DynamoExpression }=require('dynamo-update-expr')
const values = [
{
key: 'user.name.first',
value: 'John'
},
{
key: 'user.name.last',
value: 'Doe'
},
{
key: 'user.data',
value: {
age: 24,
location: 'Manglore'
}
},
{
key: 'name',
value: 'Shashank'
}
]
let expr = new DynamoExpression().set(values);
console.log(expr.asExpression());
Methods
set
function to generate a DynamoExpression which will SET some values in the DB
Parameters
Returns DynamoExpression expr
Type - SetParam
interface SetParam {
key: string;
value: any;
}
asExpression
function to get the expression object to directly pass to the Dynamodb update call
Returns Expression generated dynamo expression
Type - Expression
interface Expression {
ExpressionAttributeNames: Record<string,any>;
ExpressionAttributeValues: Record<string,any>;
UpdateExpression: string;
}
Please feel free to create pull requests or feature requests.