-
Notifications
You must be signed in to change notification settings - Fork 213
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
[DynamoDB] Support Document Types #308
Comments
@cjwebb Personally I only use |
@alimoeeny thanks for the quick reply. You are indeed correct that dynamodb now basically has full json support. As mentioned, I'm not sure how I'd go about adding this to |
@alimoeeny Can you clarify what you mean when you say you "use String and convert or unmarshal everything back and forth manually"? I have the same issue as @cjwebb - I want to use List and Map and the functionality is not provided. |
@budadcabrion What I do is treat everything as |
If I'm understanding you correctly, the problem with this approach is that you can't update a nested part of the document without reading it back out, updating it, and writing back. Which means we're not really getting all the document features that the API supports. Ideally the DynamoDB semantics for maps could be supported via code that looks like: q := NewQuery(myTable)
ex := Expression{
Text: "SET #my.#mapkey = :mapval",
AttributeNames: map[string]string {
"#my": "my_document_column",
"#mapkey": "my_field_name",
},
// this doesn't work
AttributeValues: map[string]*Attribute{
":mapval": DynamoAttribute{S: someStringValue},
},
}
q.AddUpdateExpression(ex) As far as I can tell we can't currently use the I'm working on a project over at DramaFever where this limitation is biting me. I spent a good bit of time looking at the work @cbroglie did in #276 and I've just run into the discussion going on in a related ticket in aws/aws-sdk-go#72. Is AdRoll going to continue to support this project given that there's an official SDK library? |
This would be a question for @crowdmatt and @dialtone |
Ok, and thanks for making that @-mention for me. I also should say that I didn't mean to say "AdRoll should do this" but rather that I'm happy to contribute an extension of |
@tgross , as far as I am concerned (I have zero decision making power here), there are many many people who are already using |
@tgross @cjwebb I previously added the PutDocument/GetDocument functions to support this without breaking the API. I had planned to add a corresponding UpdateDocument function, but haven't yet needed it. I think it would be fairly straight forward to implement using the dynamizer stuff so long as your structs use the omitempty tag. |
Ok, I'll take a crack at UpdateDocument. It looks like Query/Scan APIs don't return the values of map attributes either, so I'll need to provide a QueryDocument and ScanDocument or tweak the internals of Query/Scan. In some very rough preliminary work I found that they were just being ignored, so maybe it's just a matter of deserialization. I'll investigate. Also, unless I'm mistaken PutDocument/GetDocument don't support conditional expressions or expression attribute name/values. Given the existing goamz API convention for conditional expressions, it looks like we'll need a ConditionExpressionPutDocument, ConditionExpressionUpdateDocument, and ConditionExpressionDeleteDocument. I'll toss those in too. I painted myself into a corner in my project with this requirement, so I'll almost certainly have something for you in the next couple days. I'll probably open a PR for discussion before it's entirely complete just to make sure I'm not going totally off the rails. |
That approach sounds reasonable to me. I'm not a maintainer, but I'd be happy to review what you come up with. |
Just wanted to follow up on this. The bad news is that it looks like I can't get the existing API for Query, Scan, etc. to support the same dynamizer semantics as PutDocument/GetDocument. The problem I'm running into is in using FromDynamo with a collection of results because of the way it uses an untyped out-parameter (i.e. The good news is that I've got an almost-entirely-working and backwards-compatible way to improve Attribute and some other supporting functions so that all the existing Query, Scan, etc, etc. functions can support the map type. The last bit I have to do is to fix UntypedQuery.AddUpdates so that it can update a field within the map and I'll be good-to-go. I'll have a PR for the latter work within 24 hours (including lots of new tests). I honestly like the dynamizer API better from the standpoint of consuming the library, but I can't make it work myself. |
I have only been using goamz for a few days, but it does not appear to support DynamoDB's document types
List
andMap
. Have I missed something? Is this planned for the future?Even if it isn't planned, help would be appreciated, as due to the nature of the
Attribute
struct, I'm not entirely sure how to add it without making breaking changes...The text was updated successfully, but these errors were encountered: