🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

dynamodb-storage-backend

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamodb-storage-backend - npm Package Compare versions

Comparing version

to
1.0.9

test/storage/backend-methods.js

47

lib/storage/dynamodb-storage.js

@@ -56,3 +56,2 @@ 'use strict';

// Apply dynamodb endpoint
if (!variables.hasOwnProperty('dynamodb')) throw new Error("DynamoDB instance must be provided");

@@ -65,7 +64,5 @@

/**
* Load entity content container for entity data.
* Returns assigned DynamoDB Instance.
*
* @param id
* entity id data
* @param callback
* @return instance
*/

@@ -75,2 +72,16 @@

_createClass(DDBStorageBackend, [{
key: 'getDynamoDBInstance',
value: function getDynamoDBInstance() {
return this._registry.get("properties", 'dynamodb');
}
/**
* Load entity content container for entity data.
*
* @param id
* entity id data
* @param callback
*/
}, {
key: 'loadEntityContainer',

@@ -143,3 +154,2 @@ value: function loadEntityContainer(entityId, callback) {

value: function saveDataItem(table, data, callback) {
var dynamodb = this._registry.get("properties", 'dynamodb');
var params = {

@@ -149,3 +159,3 @@ TableName: table,

};
dynamodb.putItem(params, function (err, result) {
this.getDynamoDBInstance().putItem(params, function (err, result) {
// TODO: Handle throttling

@@ -170,3 +180,2 @@ // TODO: Handle eventually consisency issues...

var dynamodb = this._registry.get("properties", 'dynamodb');
var params = {

@@ -178,3 +187,3 @@ TableName: table,

// TODO: Handle eventually consisency issues...
dynamodb.getItem(params, function (err, result) {
this.getDynamoDBInstance().getItem(params, function (err, result) {
callback(err, _this2.decodeMap(result.Item));

@@ -197,3 +206,2 @@ });

var dynamodb = this._registry.get("properties", 'dynamodb');
var params = {

@@ -205,3 +213,3 @@ TableName: table,

// TODO: Handle eventually consisency issues...
dynamodb.deleteItem(params, function (err, result) {
this.getDynamoDBInstance().deleteItem(params, function (err, result) {
callback(err, _this3.decodeMap(result.Item));

@@ -228,3 +236,2 @@ });

var indexeDefinitions = this.getStorageIndexDefinitions();
var dynamodb = this._registry.get("properties", 'dynamodb');
var maxItems = 100;

@@ -239,3 +246,3 @@ var pointer = 0;

dynamodb.batchGetItem(params, function (err, data) {
self.getDynamoDBInstance().batchGetItem(params, function (err, data) {
if (err) return callback(err);

@@ -270,3 +277,3 @@

/**
* Return storege domain.
* Return storege domain defined by storage handler.
*

@@ -283,2 +290,14 @@ * @return storage domain

/**
* Returns prefix for table defined by storage handler.
*
* @return storage domain
*/
}, {
key: 'getStorageTablePrefix',
value: function getStorageTablePrefix() {
return this.getStorageHandler().getStorageTablePrefix();
}
/**
* Return storege domain.

@@ -285,0 +304,0 @@ *

{
"name": "dynamodb-storage-backend",
"version": "1.0.8",
"version": "1.0.9",
"description": "DynamoDB storage backend",

@@ -37,4 +37,4 @@ "main": "lib/index.js",

"dependencies": {
"entity-api": "0.0.14"
"entity-api": "0.0.23"
}
}

@@ -29,3 +29,2 @@ import DomainMap from 'domain-map'

// Apply dynamodb endpoint
if (!variables.hasOwnProperty('dynamodb'))

@@ -37,3 +36,13 @@ throw new Error("DynamoDB instance must be provided");

/**
* Returns assigned DynamoDB Instance.
*
* @return instance
*/
getDynamoDBInstance() {
return this._registry.get("properties", 'dynamodb');
}
/**
* Load entity content container for entity data.

@@ -99,3 +108,2 @@ *

saveDataItem(table, data, callback) {
let dynamodb = this._registry.get("properties", 'dynamodb');
let params = {

@@ -105,3 +113,3 @@ TableName: table,

}
dynamodb.putItem(params, (err, result) => {
this.getDynamoDBInstance().putItem(params, (err, result) => {
// TODO: Handle throttling

@@ -121,3 +129,2 @@ // TODO: Handle eventually consisency issues...

loadDataItem(table, itemKey, callback) {
let dynamodb = this._registry.get("properties", 'dynamodb');
let params = {

@@ -129,3 +136,3 @@ TableName: table,

// TODO: Handle eventually consisency issues...
dynamodb.getItem(params, (err, result) => {
this.getDynamoDBInstance().getItem(params, (err, result) => {
callback(err, this.decodeMap(result.Item));

@@ -143,3 +150,2 @@ })

deleteDataItem(table, itemKey, callback) {
let dynamodb = this._registry.get("properties", 'dynamodb');
let params = {

@@ -151,3 +157,3 @@ TableName: table,

// TODO: Handle eventually consisency issues...
dynamodb.deleteItem(params, (err, result) => {
this.getDynamoDBInstance().deleteItem(params, (err, result) => {
callback(err, this.decodeMap(result.Item));

@@ -171,3 +177,2 @@ })

let indexeDefinitions = this.getStorageIndexDefinitions();
let dynamodb = this._registry.get("properties", 'dynamodb');
let maxItems = 100;

@@ -182,3 +187,3 @@ let pointer = 0;

dynamodb.batchGetItem(params, (err, data) => {
self.getDynamoDBInstance().batchGetItem(params, (err, data) => {
if (err) return callback(err)

@@ -216,3 +221,3 @@

/**
* Return storege domain.
* Return storege domain defined by storage handler.
*

@@ -226,2 +231,11 @@ * @return storage domain

/**
* Returns prefix for table defined by storage handler.
*
* @return storage domain
*/
getStorageTablePrefix() {
return this.getStorageHandler().getStorageTablePrefix();
}
/**
* Return storege domain.

@@ -228,0 +242,0 @@ *

@@ -103,2 +103,3 @@ import DynamoDBStorageBackend from "./../../src/index"

describe('Schema installation', () => {
it('It should install schemas', done => {

@@ -127,3 +128,3 @@ let entityTypeId = 'test';

describe('Schema storage', () => {
it('It should save and load data from schema tables', done => {
it('It should save, load and delete data from schema tables', done => {
let entityTypeId = 'test';

@@ -130,0 +131,0 @@ AWS.config.update({