aws / aws-sdk-ruby-record

Official repository for the aws-record gem, an abstraction for Amazon DynamoDB.
Apache License 2.0
318 stars 41 forks source link

Why was this gem created? #48

Closed NielsKSchjoedt closed 7 years ago

NielsKSchjoedt commented 7 years ago

Hi,

I'm going to start a rather big project using ruby and dynamoDB. I first stumbled upon this gem: https://github.com/Dynamoid/Dynamoid and then came across this one too. Now I'm wondering: Why was this one created a year ago, then Dynamoid was already around? Is there any particular reason that could guide me towards which one I should use... :-)

awood45 commented 7 years ago

This gem was created in response to customer feedback asking for it, bringing the AWS::Record functionality from V1 of the AWS SDK for Ruby to V2 of the SDK.

awood45 commented 7 years ago

I'm not intimately familiar with Dynamoid, so I'm not sure how to provide a direct comparison of which gem would be better for your needs. What I can do is answer questions about what you're trying to do with DynamoDB and how this gem could help.

awood45 commented 7 years ago

Going to close this as the initial question is answered, but feel free to reopen/reach out if you have project specific questions. Thanks!

NielsKSchjoedt commented 7 years ago

Hey, thanks for response.

I'm building sort of a cache for some simple objects which has around 20 meta data attributes and a couple of serialised attributes in either JSON or YAML (they don't have to be indexable, so all good here).

The functionality I'm looking for is specifically related to the creation of the objects. I would like to utilise dynamodb's ability to make a UpdateItem request rather than a PutItem request, also for new objects.

The reason for this is, that I would like to be able to avoid a roundtrip to Dynamodb for checking if my hash_key already exists every time I need to create a new object.

Instead I would just like to create the object with all changed (dirty) attrs if it's not there, or alternatively update the existing one with the changed attrs if it's already there (a bit like postgres's upsert functionality). Is this possible with the current implementation of the gem? Also i would like to get ALL values of the record in return of the UpdateItem call, so that the object I have is reloaded with whatever attributes was already present on object, if it was in fact already existing.

NielsKSchjoedt commented 7 years ago

I have started to answer my own question: https://github.com/aws/aws-sdk-ruby-record/pull/50 👍

awood45 commented 7 years ago

I think that is the place to continue this discussion, yes. Worst case, we could even expose an explicit "upsert" functionality rather than #save. I think in either case the underlying work is the same.