Support incrementing values and set operations in transactions
@andrykonchin Congrats on getting transactions released!
Here's an initial idea for supporting incrementing values and set operations in transactions that we decided wouldn't make the cut for v1 of transactions. https://github.com/Dynamoid/dynamoid/pull/846
Incrementing values is exceptionally useful in transactions. A record can be created and a counter incremented in a transaction to guarantee an accurate count. For accounting a debit and credit could be done in a transaction to ensure consistency.
I put this in an update() method which seems consistent with other code. If we want to go this direction I can put the specs back in for this as well.
We previously also had block support on upserts. This is useful because a counter can be incremented without checking it's been created first but perhaps supporting this now is not needed.
Sorry, for some reason I thought 3.11 had already been released. I jumped the gun.
Hello. Thank you!
Regarding incrementing values. Yes, it indeed makes sense to support these add/set/delete low-level operations in transactions. And using interface of the update method is a proper way to do so IMHO. Will leave comments in the PR #846.
Just for the record - there are methods increment/decrement in Dynamoid that work similarly to their Rails' counterparts and update integer attributes in atomic way. They also finally will be supported in transactions.
There are also several other ActiveRecord's methods similar to them (decrement_counter, increment_counter, reset_counters, update_counters) that I am planning to add as well.
Sorry, for some reason I thought 3.11 had already been released. I jumped the gun.
The v3.11.0 version was indeed released a couple of days ago.
The changes were made in #846. So close this issue as completed.