Skip to content

Commit

Permalink
Update Readme.md document and add warning about experimental feature
Browse files Browse the repository at this point in the history
  • Loading branch information
andrykonchin committed Dec 28, 2024
1 parent 23b2768 commit 14a28de
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1048,19 +1048,23 @@ on the base table*

### Transactions in Dynamoid

> [!WARNING]
> Please note that this API is experimental and can be changed in
> future releases.
Multiple modifying actions can be grouped together and submitted as an
all-or-nothing operation. Atomic modifying operations are supported in
Dynamoid using transactions. If any action in the transaction fails they
all fail.

The following actions are supported:

* `#create` - add a new model if it does not already exist
* `#save` - create or update model
* `#update_attributes` - modifies one or more attributes from an existig
model
* `#create`/`#create!` - add a new model if it does not already exist
* `#save`/`#save!` - create or update model
* `#update_attributes`/`#update_attributes!` - modifies one or more attributes from an existig
model
* `#delete` - remove an model without callbacks nor validations
* `#destroy` - remove an model
* `#destroy`/`#destroy!` - remove an model
* `#upsert` - add a new model or update an existing one, no callbacks
* `#update_fields` - update a model without its instantiation

Expand Down Expand Up @@ -1088,7 +1092,7 @@ Dynamoid::TransactionWrite.execute do |txn|
txn.create(User, id: user_id)
txn.create(UserEmail, id: "UserEmail##{email}", user_id: user_id)
txn.create(Address, id: 'A#2', street: '456')
txn.upsert(Address, id: 'A#1', street: '123')
txn.upsert(Address, 'A#1', street: '123')
end
```

Expand Down Expand Up @@ -1158,7 +1162,7 @@ user.red = true

Dynamoid::TransactionWrite.execute do |txn|
if txn.save(user) # won't raise validation exception
txn.update(UserCount, id: 'UserCount#Red', count: 5)
txn.update_fields(UserCount, user.id, count: 5)
else
puts 'ALERT: user not valid, skipping'
end
Expand All @@ -1174,7 +1178,7 @@ transaction = Dynamoid::TransactionWrite.new

transaction.create(User, id: user_id)
transaction.create(UserEmail, id: "UserEmail##{email}", user_id: user_id)
transaction.upsert(Address, id: 'A#1', street: '123')
transaction.upsert(Address, 'A#1', street: '123')

transaction.commit # changes are persisted in this moment
```
Expand Down

0 comments on commit 14a28de

Please sign in to comment.