clarkie / dynogels

DynamoDB data mapper for node.js. Originally forked from https://github.com/ryanfitz/vogels
Other
491 stars 110 forks source link

What is the best way to convert a list of objects #168

Closed digvijayy closed 5 years ago

digvijayy commented 5 years ago

dynogels returns attrs instead of plain JSON. I see that they get autoconverting when serializing or deserializing. What is the best way to convert them to plain JSON within the application?

cdhowie commented 5 years ago

The get() method of a document object will return the POD object behind it. So, if you have done a query/scan and want to convert all of the response document objects into POD objects, you can just do:

const podObjects = response.Items.map(i => i.get());