I want to use DynamoDb and want to use it with rails. I have found that the dynamoid gem seems to be the most used Dynamo ORM library for ruby.
I understand that the Dynamoid documentation uses hash/range key terminology (old terminology)
However I am running into a problem where I want to have compound attributes in my partition key.
For a simple example say that I have a Products
table that has an product_id
and a title
.
The primary partition key for this item will just be the product_id
Now say that I have another table Orders
. I want the primary partition key to be: orders##
. I.e I want to have compound attributes in the primary partition key as outlined in this document: https://aws.amazon.com/blogs/database/choosing-the-right-dynamodb-partition-key/ with the attributes seperated by a hash.
I found this post https://github.com/Dynamoid/Dynamoid/issues/265 that outlines how to use compound attributes with range
but this only takes care of sort-keys.
I have tried things like:
class Order
include Dynamoid::Document
key: "Order##{:product_id.to_s}##{:datetime.to_s}"
field :product_id
field :datetime
end
But this of course does not work and causes issues when initializing the table.
Is this possible with dynamoid? Such primary key naming seems to be common among aws documentation? I have not found this in the documentation.
thanks
Aucun commentaire:
Enregistrer un commentaire