@xapp/dynamo-service
Advanced tools
Comparing version 0.0.52 to 0.0.53
@@ -13,3 +13,2 @@ "use strict"; | ||
const Object_1 = require("../utils/Object"); | ||
const util_1 = require("util"); | ||
class DynamoService { | ||
@@ -20,3 +19,3 @@ constructor(db) { | ||
put(TableName, obj, condition = {}) { | ||
if (util_1.isArray(obj)) { | ||
if (Array.isArray(obj)) { | ||
return this.batchWrites(TableName, createPutBatchWriteRequests(obj)).then(unprocessed => { | ||
@@ -23,0 +22,0 @@ const unProcessedItems = []; |
@@ -33,5 +33,7 @@ "use strict"; | ||
primaryKeys.push(key); | ||
this.constantKeys.push(key); | ||
} | ||
if (v.sort) { | ||
sortKeys.push(key); | ||
this.constantKeys.push(key); | ||
} | ||
@@ -100,2 +102,3 @@ if (v.required) { | ||
ensureNoInvalidCharacters(this.bannedKeys, set); | ||
ensureNoExtraKeys(this.knownKeys, set); | ||
return this.db.update(this.tableName, key, { set, remove, append }, conditionExpression, returnType); | ||
@@ -153,5 +156,7 @@ } | ||
function ensureNoExtraKeys(knownKeys, obj) { | ||
for (const key of Object.keys(obj)) { | ||
if (knownKeys.indexOf(key) < 0) { | ||
throw new Error("Key '" + key + "' is not defined in the table."); | ||
if (obj) { | ||
for (const key of Object.keys(obj)) { | ||
if (knownKeys.indexOf(key) < 0) { | ||
throw new Error("Key '" + key + "' is not defined in the table."); | ||
} | ||
} | ||
@@ -164,5 +169,2 @@ } | ||
if (typeof value === "string") { | ||
console.log("Checking key " + value + " " + key); | ||
console.log(bannedKeys); | ||
console.log(bannedKeys[key].test(value)); | ||
if (bannedKeys[key].test(value)) { | ||
@@ -169,0 +171,0 @@ throw new Error("Invalid character found in key '" + value + "'."); |
{ | ||
"name": "@xapp/dynamo-service", | ||
"version": "0.0.52", | ||
"version": "0.0.53", | ||
"description": "A dynamo help class which will help maintain data integrity.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
3709
138102