aws-dynamodb-document-api
Usage
Credentials
require('aws-dynamodb-document-api').credentials.profile(<profile:string>, <region:string>);
require('aws-dynamodb-document-api').credentials.loadFromPath(<path to config:string>, <region:string>);
Install
npm install aws-sdk --save
npm install
Initialize
var dynamoDb = require('aws-dynamodb-document-api');
var dynamoDoc = dynamoDb.document;
dynamoDoc.setPrimaryKey(<table primary key:string>);
CRUD
dynamoDoc.create(<table name:string>, <property:object>);
dynamoDoc.get(<table name:string>, <table primary keys:object>);
dynamoDoc.update(<table name:string>, <property:object>);
dynamoDoc.removeById(<table name:string>, <table primary keys:object>);
CRUD (Create Example)
var dynamoDb = require('aws-dynamodb-document-api');
var dynamoDoc = dynamoDb.document;
dynamoDoc.setPrimaryKey('id');
dynamoDoc.create('books_by_stephen_king', {
id: '2016',
author: 'Stephen King',
title: 'End of Watch',
price: 30.00,
metadata: {
rating: 5
}
}).then(function(response) {
console.log(response.message);
}).error(function(response) {
console.log(response.message);
})