Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning unmarshalled results. #53

Open
mvivirito opened this issue Feb 3, 2021 · 3 comments
Open

Returning unmarshalled results. #53

mvivirito opened this issue Feb 3, 2021 · 3 comments

Comments

@mvivirito
Copy link

I am having issues returning the results of the queries in unmarshalled format for example with projection expression:
Querying by radius, looking 100km from Cambridge, UK.
[ { geoJson: { S: '{"type":"POINT","coordinates":[-0.13,51.51]}' } } ]

I would like to return:
Querying by radius, looking 100km from Cambridge, UK.
[ { geoJson: {"type":"POINT","coordinates":[-0.13,51.51]} } } ]

How can I achieve this?

@therealsebo
Copy link

You might use the DynamoDB Converter to marshall / unmarshall your data

https://github.com/aws/aws-sdk-js/blob/6efa2feff8d9ec1400a52c749998a747adb58f58/lib/dynamodb/converter.js#L200

@mvivirito
Copy link
Author

Where would I call that function. It seems that when I actually use it in my code that I get an empty response. It was showing up at least a couple datapoints prior to using it.

@nattapat0255
Copy link

nattapat0255 commented Dec 1, 2021

@mvivirito Your data is an array type but unmarshall function requires an object so you should convert following like below

var shopList = shops.map((shop) => {
                // Convert DynamoDB Json to Normal Json
                return AWS.DynamoDB.Converter.unmarshall(shop)
            })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants