aws / aws-record-ruby

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

Support for custom Update expressions #137

Closed lsglick closed 1 year ago

lsglick commented 1 year ago

Occasionally we would like to use Update expressions for more advanced updates than seem to be available when modifying an attribute and using the existing #update methods. We particularly need this for transactions.

For example:

It would be great if there were a way to do this in special cases while still largely taking advantages of the conveniences afforded by this SDK.

Unfortunately, update_expression is always set directly with no opportunity to override it.

E.g. Item Operations: https://github.com/aws/aws-sdk-ruby-record/blob/92e0070eea16698e23be8e31d3a36e681dc079e9/lib/aws-record/record/item_operations.rb#L609

E.g. Transactions: https://github.com/aws/aws-sdk-ruby-record/blob/92e0070eea16698e23be8e31d3a36e681dc079e9/lib/aws-record/record/transactions.rb#L294

Some potential ideas:

Thanks!

mullermp commented 1 year ago

Thanks for opening an issue. Tagging as a feature request. I am happy to review any pull requests if you have bandwidth. I recently plumbed through some options to save and update. I think option 1 (using opts, generally, over default values) is reasonable and I'd like to see that throughout item_operations and transactions usage.

lsglick commented 1 year ago

@mullermp I took a pass at it in #138. Let me know what you think!

There's a bit of logic duplication, but I was mostly trying to following existing structure in the repo.