/dynamo-helpers

a simple library with helpers to move from standard js objects to dynamo objects and back.

Primary LanguageJavaScript

dynamo-helpers

npm install dynamo-helpers

a simple helper library that takes a standard JS object, and turns it into an object that can be inserted into dynamodb and turns an object from dynamodb back into a standard JS object.

Example

objectToDynamo

var dynamoHelpers = require("dyanmo-helpers");

var object = {
	cool: "teen",
	wow: 2,
	conor: ["really", "cool", "guy"],
	numbers: [1, 2, 3]
};

var dynamoObject = dynamoHelpers.objectToDynamo(object); 
/* returns
* {
*	cool: {"S": "teen"},
*	wow: {"N": 2},
*	conor: {SS: ["really", "cool", "guy"]},
*	numbers: {NS: [1, 2, 3]}
* }
*/

dynamoToObject

var dynamoHelpers = require("object2dynamo");

var dynamoObject = {
	cool: {"S": "teen"},
	wow: {"N": 2},
	conor: {SS: ["really", "cool", "guy"]},
	numbers: {NS: [1, 2, 3]}
 };

var object = dynamoHelpers.dynamoToObject(dynamoObject);

/* returns 
* {
*	cool: "teen",
*	wow: 2,
*	conor: ["really", "cool", "guy"],
*	numbers: [1, 2, 3]
* }
*/

Test

npm test to run tests.