cascadeenergy / dynamodb-marshaler Goto Github PK
View Code? Open in Web Editor NEWTranslates sane javascript objects (and JSON) into DynamoDb format and vice versa.
License: MIT License
Translates sane javascript objects (and JSON) into DynamoDb format and vice versa.
License: MIT License
I (still) use ddb-marshaler to process streams which come through in the ddb format.
DocumentClient does not expose a mechanism for translating arbitrary data to ddb's format and back, so this lib is my only option AFAIK.
Don't deprecate it quite yet?
This should convert empty string to null automatically because dynamodb does not support empty string.
DynamoDb does not accept empty strings and simply throws an error.
Would it make sense for the marshaler to replace empty strings with null? Perhaps make it configurable what value should be substituted for empty strings.
I currently have some tests set up for my project which uses the marshaller.
The tests are run with https://github.com/hapijs/lab which detects memory leaks. When this project is required anywhere in the code i get the following warning at the end :
The following leaks were detected:__core-js_shared__
Don't know where this happens in the code but it's certainly coming from this module.
The version in package.json is 1.2.2 but the published npm version is 2.0.0
When I unmarshal the following:
{ foo: { SS: [ 'foo1', 'foo2' ] } }
I get { foo: {} }
I kinda like how aws labs does their setup:
var awsClient = AWS.DynamoDB();
var docClient = new DOC.DynamoDB(awsClient);
... that way we don't have to sprinkle marshalItem
calls in our data structures
I have a problem when using dynamoDB, the error content : "Encountered unexpected item".
Please help me fix bug above.
I found that dynamodb wasn't allowing string arrays which included empty strings and breaking (the data I have to work with is somewhat chaotic).
["foo", ""] -> {"SS": ["foo", ""] } //apparently breaks Dynamo
I've patched it simply by filtering out empty strings on string arrays, but I'm worried that there must be a diff with our babel minor versions or something because the diff is huge. Would you still want a PR or is there something else I can do to make this a nicer PR?
I am a total noob when it comes to node and npm. Is there a way I could use this library without node? Could I load the library purely using html and js and then call the functions (especially unmarshal) in my js code?
Hi there,
I believe v1.1.0 is giving me this:
(master) addl1006018:tmp $ cat index.js
var db = require('dynamoDb-marshaler');
(master) addl1006018:tmp $ cat package.json
{
"name": "blah",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"dynamodb-marshaler": "^1.1.0"
}
}
(master) addl1006018:tmp $ node index.js
module.js:338
throw err;
^
Error: Cannot find module 'babel/polyfill'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/dank/Documents/code/tmp/node_modules/dynamoDb-marshaler/marshalItem.js:15:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
(master) addl1006018:tmp $
Forcing the version to 1.0.0, and it works again.
Please let me know if you need anything else, thanks.
Daniel
Just wondering is there a particular reason why the babel runtime is a main dependency rather that a dev one? It increases the size of the package by nearly 6Mb when you download it on npm
. While that normally doesn't matter server side it is a problem when using the library in AWS Lambda because startup time and execution speed are influenced by the size of the zip file you upload.
Hello!
Really appreciating this library as it has saved me lots of time. However, I ran into a potential edge case when I realized that the order of my array was being changed when I inserted it into Dynamo. As stated here a String Set type will be used for an array of unique values, however Dynamo does not preserve order for sets.
I have a case where I need an ordered list of strings, so the List type would need to be used. Could this potentially be an option/configuration somewhere? Also to note is that the default in the DynamoDB console when an array is created in JSON view is to create a list.
This should convert empty string to null automatically because dynamodb does not support empty string.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.