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
Add utility for unmarshalling dynamodb Query Items. #696
Comments
Hi @sanathp thanks for contacting us. You are correct the SDK does not currently provide an utility method to unmarshal a slice of |
Marking this as a Feature Request to make receiving items from query API operations easier to unmarshal into Go value types. We're also always glad to review PR if you're looking to contribute this feature to the SDK. |
I ran into this same issue. It seems strange to not have a native way to unmarshal the return types of both func UnmarshalListOfMaps(l []map[string]*dynamodb.AttributeValue, out interface{}) error {
attrs := make([]*dynamodb.AttributeValue, len(l))
for i, m := range l {
attrs[i] = &dynamodb.AttributeValue{M: m}
}
return dynamodbattribute.UnmarshalList(attrs, out)
} |
Not to harp on this but asking end users to incur N*2 marshaling time for a common return type doesn't seem like the answer. I did some digging and given that the above code is essentially just upcasting each item in |
Thanks for the feedback @twoism. I'll forward your feedback along to the DynamoDB team to help improve the API. We wouldn't be able to change the API due to the breaking change without the service doing a major version bump. To resolve this feature request I think would solve it similar to the example you posted, same for encoding. The SDK already does this to a more limited degree for marshal of list and maps. So updating to unmarshal a list of maps is pretty straightforward, but like you mentioned has more complexity. I'm not sure yet how the marshaler side of this would work yet though. Not sure its even needed though, but may make sense for parity. |
Thanks for bringing up this issue. Change #897 Fixes this issue by adding a |
This is awesome, thanks a ton! |
I know this is an old issue but could someone explain the usage ? |
Query returns items in the below format
Items []map[string]*AttributeValue
I cannot see any UnMarshal function which supports the datatype []map[string]*AttributeValue
Should I UnMarshal each element in a for loop ?? whats the best way to do this?
The text was updated successfully, but these errors were encountered: