dynamodb-simple
A simple and elegant interface for aws-sdk dynamodb documentClient
Quick Links:
Usage
You can reference aws DocumentClient documentation to get a better understanding of how these methods work under the hood
config
setup aws config You can skip this step if you already have credentials setup for aws-sdk
const dynamodbSimple = ; dynamodbSimple;
table
Create a table instance;
const dynamodbSimple = ; // with just hash// table name, hash name, range nameconst userTable = dynamodbSimple; // with hash and rangeconst userTable = dynamodbSimple;
scan
FilterExpression
queries
FilterExpression Documentation
const dynamodbSimple = ;const userTable = dynamodbSimple;const userId = 1; // hashconst name = 'Ben';const age = '30'; // scan using single attruserTable; // scan using multiple attruserTable;
query
Query using hash and range to find data. You can configure a table to use just hash or both hash and range
Write KeyConditionExpression
queries
KeyConditionExpression Documentation
const dynamodbSimple = ;const userId = 1; // hashconst age = '30'; // rangeconst name = 'ben'; // query using just hash. This is dependent on how your table is configuredconst userTable = dynamodbSimple;dynamodbSimple; // query using hash and range. This is dependent on how your table is configuredconst userTableWithRange = dynamodbSimple;userTableWithRange; // query using hash and range with other attributes. This is dependent on how your table is configureduserTableWithRange;
get
Get using hash and range to find data. You can configure a table to use just hash or both hash and range
const dynamodbSimple = ;const userId = 1; // hashconst age = '30'; // range // get using just hash. This is dependent on how your table is configuredconst userTable = dynamodbSimple;userTable; // get using hash and range. This is dependent on how your table is configuredconst userTableWithRange = dynamodbSimple;userTableWithRange;
put
Put data
const dynamodbSimple = ;const userTable = dynamodbSimple; // get using just hash. This is dependent on how your table is configuredlet newUser = name: 'ben' age: 30;userTable;
update
Put data
const dynamodbSimple = ;const userTable = dynamodbSimple;const userId = 1; // hashconst newName = 'Colton';const bestFriend = 'Rich'; // update 1 propertyuserTable; // update multiple propertiesuserTable;
delete
Delete data
const dynamodbSimple = ;const userId = 1;const age = 30; // get using just hash. This is dependent on how your table is configuredconst userTable = dynamodbSimple;userTable; // get using hash and range. This is dependent on how your table is configuredconst userTableWithRange = dynamodbSimple;userTableWithRange;
createTable
Create Table
const dynamodbSimple = ; dynamodbSimple;
deleteTable
Delete table
const dynamodbSimple = ; dynamodbSimple;
listTables
List data
const dynamodbSimple = ; dynamodbSimple;
describeTable
List data
const dynamodbSimple = ; dynamodbSimple;