Skip to content

Commit

Permalink
Using new Document static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fishcharlie committed Apr 4, 2020
1 parent 95d04fe commit 641c725
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Condition.js
Expand Up @@ -109,7 +109,7 @@ Condition.prototype.requestObject = function() {
}

object.ExpressionAttributeNames[keys.name] = key;
object.ExpressionAttributeValues[keys.value] = Document({}).toDynamo(value, {"type": "item"});
object.ExpressionAttributeValues[keys.value] = Document.toDynamo(value, {"type": "value"});

let expression = "";
switch (condition.type) {
Expand All @@ -121,7 +121,7 @@ Condition.prototype.requestObject = function() {
delete object.ExpressionAttributeValues[keys.value];
expression = `${keys.name} IN (${value.map((v, i) => `${keys.value}-${i + 1}`).join(", ")})`;
value.forEach((valueItem, i) => {
object.ExpressionAttributeValues[`${keys.value}-${i + 1}`] = Document({}).toDynamo(valueItem, {"type": "item"});
object.ExpressionAttributeValues[`${keys.value}-${i + 1}`] = Document.toDynamo(valueItem, {"type": "value"});
});
break;
case "GT":
Expand All @@ -132,8 +132,8 @@ Condition.prototype.requestObject = function() {
break;
case "BETWEEN":
expression = `${keys.name} BETWEEN ${keys.value}-1 AND ${keys.value}-2`;
object.ExpressionAttributeValues[`${keys.value}-1`] = Document({}).toDynamo(value[0], {"type": "item"});
object.ExpressionAttributeValues[`${keys.value}-2`] = Document({}).toDynamo(value[1], {"type": "item"});
object.ExpressionAttributeValues[`${keys.value}-1`] = Document.toDynamo(value[0], {"type": "value"});
object.ExpressionAttributeValues[`${keys.value}-2`] = Document.toDynamo(value[1], {"type": "value"});
delete object.ExpressionAttributeValues[keys.value];
break;
case "CONTAINS":
Expand Down

0 comments on commit 641c725

Please sign in to comment.