@xapp/dynamo-service
Advanced tools
Comparing version 0.0.48 to 0.0.49
@@ -61,3 +61,3 @@ "use strict"; | ||
put(obj, condition) { | ||
Object_1.throwIfDoesNotContain(obj, this.requiredKeys); | ||
ensureHasRequiredKeys(this.requiredKeys, obj); | ||
const putObj = (this.props.trimUnknown) ? Object_1.subset(obj, this.knownKeys) : obj; | ||
@@ -72,3 +72,3 @@ const primaryExistsQuery = (this.sortKey) ? | ||
putAll(obj) { | ||
obj.forEach(o => Object_1.throwIfDoesNotContain(o, this.requiredKeys)); | ||
obj.forEach(o => ensureHasRequiredKeys(this.requiredKeys, o)); | ||
const putObjs = (this.props.trimUnknown) ? | ||
@@ -85,5 +85,5 @@ obj.map(o => Object_1.subset(o, this.knownKeys)) : | ||
update(key, obj, conditionExpression, returnType) { | ||
Object_1.throwIfDoesContain(obj.remove, this.constantKeys.concat(this.requiredKeys)); | ||
Object_1.throwIfDoesContain(obj.set, this.constantKeys); | ||
Object_1.throwIfDoesContain(obj.append, this.constantKeys); | ||
ensureDoesNotHaveConstantKeys(this.constantKeys.concat(this.requiredKeys), obj.remove); | ||
ensureDoesNotHaveConstantKeys(this.constantKeys, obj.set); | ||
ensureDoesNotHaveConstantKeys(this.constantKeys, obj.append); | ||
return this.db.update(this.tableName, key, obj, conditionExpression, returnType); | ||
@@ -124,1 +124,17 @@ } | ||
exports.TableService = TableService; | ||
function ensureHasRequiredKeys(requiredKeys, obj) { | ||
try { | ||
Object_1.throwIfDoesNotContain(obj, requiredKeys); | ||
} | ||
catch (e) { | ||
throw new Error("The the object requires the keys '" + requiredKeys.join(",") + "'."); | ||
} | ||
} | ||
function ensureDoesNotHaveConstantKeys(constantKeys, obj) { | ||
try { | ||
Object_1.throwIfDoesContain(obj, constantKeys); | ||
} | ||
catch (e) { | ||
throw new Error("The keys '" + constantKeys.join(",") + "' are constant and can not be modified."); | ||
} | ||
} |
{ | ||
"name": "@xapp/dynamo-service", | ||
"version": "0.0.48", | ||
"version": "0.0.49", | ||
"description": "A dynamo help class which will help maintain data integrity.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
128715
3494