Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check ItemSize DynamoDB in Node.js

I use the dynamo set function to store data in DynamoDB, but sometimes the data is too big. Is there a function that I can use to determine if the data is too big to be saved in DynamoDB? a Node js function? Thanks

This should work even if the data is an object with arrays and other objects.

I tried to npm module object-sizeof, does that work?

like image 580
Chris Hansen Avatar asked Jul 03 '26 01:07

Chris Hansen


1 Answers

You can use dyno-item-size module to get the item size.

var dynoItemSize = require('dyno-item-size');
var size = dynoItemSize(item);

var params = {
    TableName : table,
    Item : {
        "autoID" : "yyy",
        "alexandriaID" : "id1",
        "docType" : "foo",
        "username" : "good",
        "userdescription" : "user description",
        "comment" : "complex condition"
    }
};

console.log("Size of item =====>" + dynoItemSize(params.Item));

References:-

ItemSize in DynamoDB http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html

An item size is the sum of lengths of its attribute names and values (binary and UTF-8 lengths);

like image 178
notionquest Avatar answered Jul 05 '26 14:07

notionquest



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!