Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dynamodb-service

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamodb-service - npm Package Compare versions

Comparing version 1.6.0 to 1.6.1

DESIGN.md

2

package.json
{
"name": "dynamodb-service",
"version": "1.6.0",
"version": "1.6.1",
"description": "Managing records saved in Dynamodb",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,4 +10,5 @@ /**

const AWS = require('aws-sdk');
// Set your region for future requests.
const ManageTable = require('./ManageTable.js');
class DynamoDBService {

@@ -22,3 +23,4 @@ /**

*/
constructor(tableName, primaryKeyName, profile, extra) {
constructor(tableName, primaryKeyName, sortKeyName, profile, extra) {
// Set your region for future requests.
extra = extra || { region: 'us-east-1' };

@@ -34,2 +36,3 @@

this.keyName = primaryKeyName;
this.sortKeyName = sortKeyName;
this.dynamoDb = new AWS.DynamoDB.DocumentClient();

@@ -39,2 +42,19 @@

/**
* @param TableName {string} required
* @param primaryKeyName {string} required
* @param sortKeyName {string} optional
* @param throuput {number} optional
* @param profile {string} optional
*/
static createTable(TableName, primaryKeyName, sortKeyName, throuput, profile, extra) {
return ManageTable.createTable(TableName, primaryKeyName, sortKeyName, throuput, profile, extra);
}
/**
* @param TableName {string} required
*/
static deleteTable(TableName, profile, extra) {
return ManageTable.deleteTable(TableName, profile, extra);
}
/**

@@ -63,3 +83,3 @@ * Save information in the DynamoDB table

return this.dynamoDb.put(params).promise()
.then((/* success */) => this.read(data[this.keyName]));
.then((/* success */) => this.read(data[this.keyName], data[this.sortKeyName]));

@@ -71,8 +91,12 @@ }

* @param id { string } The primaryKey that presents the saved records
* @param sortKey { string } The primaryKey that presents the saved records
* @return { Promise<any> }
*/
read(id) {
read(id, sortKey) {
let Key = {};
Key[this.keyName] = id;
if(sortKey){
Key[this.sortKeyName] = sortKey;
}

@@ -121,5 +145,5 @@ let params = {

*/
delete(id) {
delete(id, sortKey) {
return this.read(id).then(response => {
return this.read(id, sortKey).then(response => {

@@ -130,2 +154,5 @@ if(!!response && this.keyName in response) {

Key[this.keyName] = response[this.keyName];
if(sortKey){
Key[this.sortKeyName] = response[this.sortKeyName];
}

@@ -132,0 +159,0 @@ let params = {

@@ -15,5 +15,5 @@ /**

let id = '1';
let id = '0';
dynamodbService.delete(id) // => @return Promise
.then(createdRecord => console.log(createdRecord))
.catch(e => console.error(e.message || 'error', e));
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc