2

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?

Alexander Patrikalakis
  • 5,054
  • 1
  • 30
  • 48
Chris Hansen
  • 7,813
  • 15
  • 81
  • 165

1 Answers1

0

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);

Community
  • 1
  • 1
notionquest
  • 37,595
  • 6
  • 111
  • 105