diff --git a/lib/typeUtil.js b/lib/typeUtil.js index 6bd94bd..732b91e 100644 --- a/lib/typeUtil.js +++ b/lib/typeUtil.js @@ -90,6 +90,9 @@ function valueToObject(value) { return {N: String(value)} default: if (Array.isArray(value)) { + if (value.length == 0) + return {L: []} + var firstItemType = typeof value[0] // check that all of the items are of the same type; that of the first element's @@ -108,9 +111,13 @@ function valueToObject(value) { } return {NS: numArray} + } else if (firstItemType === "object") { + return {L: value.map(valueToObject)} } else { throw new Error('Invalid dynamo set value. Type: ' + firstItemType + ', Value: ' + value[0]) } + } else if (typeof value == "object") { + return {M: packObjectOrArray(value)} } else { // TODO(nick): I'm pretty sure this should be an error. But there is a bunch // of code relying on this behavior, so just log the error for now and @@ -139,7 +146,7 @@ function objectToType(obj) { * Convert a Dynamo AttributeValue to a javascript primitive value * * @param {!AWSAttributeValue} obj - * @return {string|number|Array.|Array.|boolean} a javascript primitive value + * @return {string|number|Array.|Array.|boolean|Object} a javascript primitive value */ function objectToValue(obj) { switch (objectToType(obj)) { diff --git a/package.json b/package.json index 5e4774f..301283e 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "dependencies": { "kew": "0.7.0", "typ": "0.6.3", - "aws-sdk": "2.2.47" + "aws-sdk": "2.5.1" }, "devDependencies": { "closure-npc": "0.1.3",