dynamodb-storage-backend
Advanced tools
Comparing version
@@ -34,4 +34,4 @@ 'use strict'; | ||
*/ | ||
var DynamoDBStorageBackend = function (_StorageBackend) { | ||
_inherits(DynamoDBStorageBackend, _StorageBackend); | ||
var DDBStorageBackend = function (_StorageBackend) { | ||
_inherits(DDBStorageBackend, _StorageBackend); | ||
@@ -48,8 +48,8 @@ /** | ||
*/ | ||
function DynamoDBStorageBackend() { | ||
function DDBStorageBackend() { | ||
var variables = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_classCallCheck(this, DynamoDBStorageBackend); | ||
_classCallCheck(this, DDBStorageBackend); | ||
var _this = _possibleConstructorReturn(this, (DynamoDBStorageBackend.__proto__ || Object.getPrototypeOf(DynamoDBStorageBackend)).call(this, variables)); | ||
var _this = _possibleConstructorReturn(this, (DDBStorageBackend.__proto__ || Object.getPrototypeOf(DDBStorageBackend)).call(this, variables)); | ||
@@ -74,3 +74,3 @@ if (variables.hasOwnProperty('lockUpdates')) _this.setStorageLock(variables.lockUpdates); | ||
_createClass(DynamoDBStorageBackend, [{ | ||
_createClass(DDBStorageBackend, [{ | ||
key: 'loadEntityContainer', | ||
@@ -196,5 +196,3 @@ value: function loadEntityContainer(entityId, callback) { | ||
// Process data | ||
Object.keys(data.Responses).forEach(function (tableName) { | ||
// Do not process empty reponses; | ||
if (!Array.isArray(data.Responses[tableName])) return; | ||
@@ -204,3 +202,2 @@ | ||
var data = self.decodeMap(rowData); | ||
// TODO: Get entity id dynamically... | ||
var entityId = self.getStorageHandler().extractEntityId(indexeDefinitions, data); | ||
@@ -210,3 +207,2 @@ result.set(entityId, data); | ||
}); | ||
getBatch(); | ||
@@ -370,3 +366,4 @@ }); | ||
/** | ||
* Select data from storage. | ||
* Select data from storage. If query doesn't contain table name, we will | ||
* populate table name to match entity specs. | ||
* | ||
@@ -429,2 +426,4 @@ * @param variables | ||
if (variables.hasOwnProperty('debug') && variables.debug) _entityApi2.default.log("DDBStorageBackend", 'Creating table: ' + schema.TableName); | ||
if (variables.method == 'scan') { | ||
@@ -533,12 +532,12 @@ dynamodb.scan(query, resultHandler); | ||
schemas.forEach(function (schema) { | ||
_entityApi2.default.log("DynamoDBStorageBackend", 'Creating table: ' + schema.TableName); | ||
_entityApi2.default.log("DDBStorageBackend", 'Creating table: ' + schema.TableName); | ||
self.installSchema(schema, options, function (err, succeed) { | ||
if (err) { | ||
_entityApi2.default.log("DynamoDBStorageBackend", err.toString(), 'error'); | ||
_entityApi2.default.log("DDBStorageBackend", err.toString(), 'error'); | ||
errors = true; | ||
} else if (succeed) { | ||
_entityApi2.default.log("DynamoDBStorageBackend", 'Table created: ' + schema.TableName); | ||
_entityApi2.default.log("DDBStorageBackend", 'Table created: ' + schema.TableName); | ||
} else { | ||
_entityApi2.default.log("DynamoDBStorageBackend", 'Table not created, already exists: ' + schema.TableName); | ||
_entityApi2.default.log("DDBStorageBackend", 'Table not created, already exists: ' + schema.TableName); | ||
} | ||
@@ -616,12 +615,12 @@ | ||
schemas.forEach(function (schema) { | ||
_entityApi2.default.log("DynamoDBStorageBackend", 'Deleting table: ' + schema.TableName); | ||
_entityApi2.default.log("DDBStorageBackend", 'Deleting table: ' + schema.TableName); | ||
self.uninstallSchema(schema, options, function (err, succeed) { | ||
if (err) { | ||
_entityApi2.default.log("DynamoDBStorageBackend", err.toString(), 'error'); | ||
_entityApi2.default.log("DDBStorageBackend", err.toString(), 'error'); | ||
errors = true; | ||
} else if (succeed) { | ||
_entityApi2.default.log("DynamoDBStorageBackend", 'Table deleted: ' + schema.TableName); | ||
_entityApi2.default.log("DDBStorageBackend", 'Table deleted: ' + schema.TableName); | ||
} else { | ||
_entityApi2.default.log("DynamoDBStorageBackend", 'Table not deleted, might be it didn\'t exists: ' + schema.TableName); | ||
_entityApi2.default.log("DDBStorageBackend", 'Table not deleted, might be it didn\'t exists: ' + schema.TableName); | ||
} | ||
@@ -666,5 +665,5 @@ | ||
return DynamoDBStorageBackend; | ||
return DDBStorageBackend; | ||
}(_entityApi.StorageBackend); | ||
exports.default = DynamoDBStorageBackend; | ||
exports.default = DDBStorageBackend; |
{ | ||
"name": "dynamodb-storage-backend", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "DynamoDB storage backend", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -11,3 +11,3 @@ import DomainMap from 'domain-map' | ||
*/ | ||
class DynamoDBStorageBackend extends StorageBackend { | ||
class DDBStorageBackend extends StorageBackend { | ||
@@ -146,5 +146,3 @@ /** | ||
// Process data | ||
Object.keys(data.Responses).forEach(tableName => { | ||
// Do not process empty reponses; | ||
if (!Array.isArray(data.Responses[tableName])) | ||
@@ -155,8 +153,7 @@ return; | ||
let data = self.decodeMap(rowData); | ||
// TODO: Get entity id dynamically... | ||
let entityId = self.getStorageHandler().extractEntityId(indexeDefinitions, data); | ||
let entityId = self.getStorageHandler() | ||
.extractEntityId(indexeDefinitions, data); | ||
result.set(entityId, data); | ||
}) | ||
}); | ||
getBatch(); | ||
@@ -314,3 +311,4 @@ }); | ||
/** | ||
* Select data from storage. | ||
* Select data from storage. If query doesn't contain table name, we will | ||
* populate table name to match entity specs. | ||
* | ||
@@ -367,2 +365,5 @@ * @param variables | ||
if (variables.hasOwnProperty('debug') && variables.debug) | ||
EntitySystem.log("DDBStorageBackend", `Creating table: ${schema.TableName}`); | ||
if (variables.method == 'scan') { | ||
@@ -464,12 +465,12 @@ dynamodb.scan(query, resultHandler); | ||
schemas.forEach(schema => { | ||
EntitySystem.log("DynamoDBStorageBackend", `Creating table: ${schema.TableName}`); | ||
EntitySystem.log("DDBStorageBackend", `Creating table: ${schema.TableName}`); | ||
self.installSchema(schema, options, (err, succeed) => { | ||
if (err) { | ||
EntitySystem.log("DynamoDBStorageBackend", err.toString(), 'error'); | ||
EntitySystem.log("DDBStorageBackend", err.toString(), 'error'); | ||
errors = true; | ||
} else if (succeed) { | ||
EntitySystem.log("DynamoDBStorageBackend", `Table created: ${schema.TableName}`); | ||
EntitySystem.log("DDBStorageBackend", `Table created: ${schema.TableName}`); | ||
} else { | ||
EntitySystem.log("DynamoDBStorageBackend", `Table not created, already exists: ${schema.TableName}`); | ||
EntitySystem.log("DDBStorageBackend", `Table not created, already exists: ${schema.TableName}`); | ||
} | ||
@@ -546,12 +547,12 @@ | ||
schemas.forEach(schema => { | ||
EntitySystem.log("DynamoDBStorageBackend", `Deleting table: ${schema.TableName}`); | ||
EntitySystem.log("DDBStorageBackend", `Deleting table: ${schema.TableName}`); | ||
self.uninstallSchema(schema, options, (err, succeed) => { | ||
if (err) { | ||
EntitySystem.log("DynamoDBStorageBackend", err.toString(), 'error'); | ||
EntitySystem.log("DDBStorageBackend", err.toString(), 'error'); | ||
errors = true; | ||
} else if (succeed) { | ||
EntitySystem.log("DynamoDBStorageBackend", `Table deleted: ${schema.TableName}`); | ||
EntitySystem.log("DDBStorageBackend", `Table deleted: ${schema.TableName}`); | ||
} else { | ||
EntitySystem.log("DynamoDBStorageBackend", `Table not deleted, might be it didn't exists: ${schema.TableName}`); | ||
EntitySystem.log("DDBStorageBackend", `Table not deleted, might be it didn't exists: ${schema.TableName}`); | ||
} | ||
@@ -600,2 +601,2 @@ | ||
export default DynamoDBStorageBackend; | ||
export default DDBStorageBackend; |
45433
0.26%