-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
Documentation on struct tags #127
Comments
They are sparsely documented here, at least for table creation. You want to add |
Are these actually enums or text strings from DynamoDB ? Can you give a hint as to where we can find a list and what each does? I'm looking at trying to make a simple datastore, but the one example seems to use the first value of a struct as automatically the Partition, the second one is the Range? Or maybe not? multiple examples, to some hints as to what the choice of markup are, or some sort of "This is how you make the 4th item the Partition Key" or "this is how you make a Range Key", or, indeed, the first element is automatically the Partition.
^^ positional? We appreciate your work and that you're offering it freely, but the guesswork really increases the cost of trying things out, whereas documentation is how you help people realize the genius of your design and implementation. What does "dynamo:ID" do? What does "dynamo:,omitempty" do, and how does it differ from "dynamo:,omitemptyelem" ? What does "dynamo:hash" do ? "dynamo:,hash" ? (there's a comma there) What does "dynamo:,range" do? What other tokens/configs/markup can we use in "dynamo:"? Is there a piece of code that lists them, that we can look at? |
@chickenandpork
You always have to specify the name of the primary keys you use for queries, it won't automatically figure them out for you. Via an overzealous PR, the example in the README incorrectly did not specify the range keys, but I have now removed those. For example, Table.Get takes the name of the hash key as its first parameter. You can find lots of examples here. Note that you don't need to specify the names of the keys for
This can be useful because DynamoDB expressions have an
One more important one is Others that have recently been added are outlined here, however, it's likely that you won't need any of them. They exist mostly for historical reasons (DynamoDB couldn't handle empty strings until recently) or for feature parity with the official SDK. In general, it will "just work" without adding any extra tags. The code that handles struct tags for encoding is here. The code for CreateTable starts here. It might also be helpful to look at the item encoding tests, which cover tests for behavior of all the struct tags. This was useful to figure out some pain points, I will use as a reference for improving the readme. |
Awesome response, @guregu :) thanks! |
finally added some documentation on struct tags in the README |
I was getting a cryptic error messages when trying to create a table, after looking at the source code I realized it was because I was missing the ID, which by the way I thought was determined by convention. The error message was
index out of range [0] with length 0
.After looking at the issues I found an issue that had this struct tag
dynamo:"id,hash"
in the code that showed how to specify the ID. Then I looked into the documentaiton to see if this was there but couldnt find anything. Is there any place where all of the possible struct tags are doucmented? I'm still trying to specify the sort key in the code.The text was updated successfully, but these errors were encountered: